-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Expand file tree
/
Copy pathupgrade-replication-scri_4.sql
More file actions
69 lines (63 loc) · 2.13 KB
/
upgrade-replication-scri_4.sql
File metadata and controls
69 lines (63 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- To avoid storing the login and password in the script file, the value
-- is passed into SQLCMD as a scripting variable. 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".
-- Enabling the replication database
-- Enable the replication database.
USE [Northwind]
GO
DECLARE @publicationDB AS sysname;
DECLARE @publication AS sysname;
DECLARE @article AS sysname;
DECLARE @login AS sysname;
DECLARE @password AS sysname;
SET @publicationDB = N'Northwind';
SET @publication = N'NwdCustomersMerge';
SET @article = N'Customers';
-- Specify the Windows account to run the Snapshot Agent.
SET @login = $(Login);
-- Supply the password at runtime.
SET @password = $(Password);
EXEC sp_replicationdboption
@dbname = @publicationDB,
@optname = N'merge publish',
@value = N'true';
-- Add the merge publication.
EXEC sp_addmergepublication
@publication = @publication,
@description = N'Merge publication of Northwind.',
@retention = 14,
@sync_mode = N'native',
@dynamic_filters = N'false',
@keep_partition_changes = N'false',
-- Only set to '90RTM' if all Subscribers are SQL Server 2005.
@publication_compatibility_level = N'90RTM',
@replicate_ddl = 1,
@allow_subscriber_initiated_snapshot = N'true',
@allow_web_synchronization = N'false',
@allow_partition_realignment = N'true',
@retention_period_unit = N'day',
@automatic_reinitialization_policy = 0,
@conflict_logging = N'both';
EXEC sp_addpublication_snapshot
@publication = @publication,
@job_login = @login,
@job_password = @password;
-- Add the merge article.
EXEC sp_addmergearticle
@publication = @publication,
@article = @article,
@source_owner = N'dbo',
@source_object = @article,
@type = N'table',
@description = null,
@column_tracking = N'true',
@schema_option = 0x0000000000034FD1,
@partition_options = 0,
@subscriber_upload_options = 0,
@identityrangemanagementoption = N'manual',
@delete_tracking = N'true',
@compensate_for_errors = N'false',
@stream_blob_columns = N'true';
GO