Thursday 29 January 2015

Adding Artical in transaction replication with schema Name change at subscriber (Not required re-initializing of snapshot)



How to add Articles in transaction replication with out reinitializing snapshot

Step-1

Please run the below command and make sure values must be '0' for the database which is participating in Replication

select immediate_sync , allow_anonymous from syspublications



If You find the values are '1' please change the values from the below commands

EXEC sp_changepublication @publication = 'Publisher name', @property =
N'allow_anonymous', @value='true'
Go
EXEC sp_changepublication @publication = 'Publisher name', @property =
N'immediate_sync', @value='true'
Go

Step-2

Adding articles to Publisher , run the below script.

exec sp_addarticle @publication = N'Publisher name',
@article = N'Publisher Articles',
@source_owner = N'dbo',
@source_object = N'Source Publisher Table',
@type = N'logbased',
@description = N'',
@creation_script = N'',
@pre_creation_cmd = N'delete',
@schema_option = 0x000000000803509F,
@identityrangemanagementoption = N'none',
@destination_table = N'Destination Table',
@destination_owner = N'Schema Name',
@status = 24,
@vertical_partition = N'false',
@ins_cmd = N'CALL [dbo].[sp_MSins_12Name_insert_sp]',
@del_cmd = N'CALL [dbo].[sp_MSdel_12Name_delete_sp]',
@upd_cmd = N'SCALL [dbo].[sp_MSupd_12Name_Update_sp]',
@force_invalidate_snapshot=1

Note;

@destination_owner = N'Schema Name', --->change the schema name here for subscriber table.

There were three sp will use in replication for moving data from PUB to SUB so please adde some name to the below red coloured space for recognising sp's

   @ins_cmd = N'CALL [dbo].[sp_MSins_12Name_insert_sp]',
   @del_cmd = N'CALL [dbo].[sp_MSdel_12Name_delete_sp]',
   @upd_cmd = N'SCALL [dbo].[sp_MSupd_12Name_Update_sp]'

Step-3

Add the subscription to publisher which we have added before.

EXEC sp_addsubscription @publication = 'Publication Name',
           @subscription_type = N'push',
           @article = 'Articles name',
           @subscriber ='Subscriber server name', @destination_db = 'Subscriber Database Name',
           @reserved='Internal'


Step-4

select * from msdb..sysjobs where name like '%Publisher name%'


Run the job of snapshot which contain step-1 '‘Snapshot Agent startup message

Make sure that you have see only added articles only snapshot will run.see the below screen shot.



From the above we have added 4 articles at a time.

when you launch the replication monitor,

First .sre and .sch ,.bcp scripts on subscriber end  then bulk inserts will inserts data from PUB to SUB find the screen shot.



No comments:

Post a Comment