Partilhar via


How to: Configure a Publication to Allow for Web Synchronization (Replication Transact-SQL Programming)

New: 5 December 2005

This topic describes the first step in configuring Web synchronization for merge replication. For an overview of the configuration process, see How to: Configure Web Synchronization for Merge Replication (Replication Transact-SQL Programming). After you complete the procedures in this topic, continue to the second step, configuring the computer that is running Microsoft Internet Information Services (IIS). This second step is described in How to: Configure IIS for Web Synchronization.

This topic describes the parameters that are required by Web synchronization. For more information about how to create publications, see How to: Create a Publication (Replication Transact-SQL Programming).

To configure a new publication

  1. At the Publisher, execute sp_addmergepublication. For @publication, specify the name of the publication and, for @allow_web_synchronization, specify a value of true. Specify any other parameters. If Subscribers will only connect to the Publisher through HTTP, also specify a value of true for @allow_anonymous.

  2. At the Publisher, to add a Snapshot Agent job for this publication, execute sp_addpublication_snapshot. For more information, see How to: Create a Publication (Replication Transact-SQL Programming).

  3. Define articles for this new publication. For more information, see How to: Define an Article (Replication Transact-SQL Programming).

To configure an existing publication

  1. Execute sp_helpmergepublication. For @publication, specify the name of the existing publication.

  2. If the value of allow_web_synchronization in the result set is 1, Web synchronization is already configured for the publication. If the value of allow_web_synchronization in the result set is 0, Web synchronization must be enabled.

  3. Execute sp_changemergepublication. For @publication, specify the name of the existing publication; for @property, specify the value allow_web_synchronization; and for @value, specify the value true.

  4. (Optional) If Subscribers will only connect to the Publisher through HTTP, execute sp_changemergepublication. For @publication, specify the name of the existing publication; for @property, specify the value allow_anonymous; and for @value, specify the value true.

Example

The following example creates a publication that is enabled for Web synchronization.

-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables  
-- on the command line and in SQL Server Management Studio, see the 
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".

--Declarations for adding a merge publication
DECLARE @publicationDB AS sysname;
DECLARE @publication AS sysname;
DECLARE @websyncurl AS nvarchar(256);
DECLARE @login AS sysname;
DECLARE @password AS sysname;
SET @publicationDB = N'AdventureWorks'; 
SET @publication = N'AdvWorksSalesOrdersMerge'; 
SET @websyncurl = 'https://' + $(WebServer) + '/WebSync';
SET @login = $(Login);
SET @password = $(Password);

-- Enable merge replication on the publication database, using defaults.
USE master
EXEC sp_replicationdboption 
  @dbname=@publicationDB, 
  @optname=N'merge publish',
  @value = N'true' 

-- Create a new merge publication, explicitly setting the defaults. 
EXEC sp_addmergepublication 
    @publication = @publication,
    -- optional parameters 
    @description = N'Merge publication of AdventureWorks using Web synchronization.',
    @publication_compatibility_level  = N'90RTM',
    -- Enable Web synchronization.
    @allow_web_synchronization = N'true',
    -- Web synchronization URL hint used by SQL Server Management Studio.
    @web_synchronization_url = @websyncurl;

-- Create a new snapshot job for the publication.
EXEC sp_addpublication_snapshot 
    @publication = @publication, 
    @job_login = @login, 
    @job_password = @password;
GO

See Also

Concepts

How to: Configure Web Synchronization for Merge Replication (RMO Programming)
Programming Replication Using System Stored Procedures

Other Resources

Web Synchronization for Merge Replication

Help and Information

Getting SQL Server 2005 Assistance