Using scripts to add a publication for an object in SQL Server transactional replication

Source: Internet
Author: User

Original: SQL Server transactional replication uses scripts to add publications for an object

--use [Publish Library]-Add Table: Create the project and add it to the publication exec sp_addarticle @publication = n ' replicationname ', @article = N ' MyObject ', @source_ Owner = n ' dbo ', @source_object = N ' MyObject ', @destination_owner = n ' dbo ', @destination_table = N ' MyObject ', @schema_optio n = 0x0000004008037fdf,---project properties (self reference) @status = 0, @description = n ",--default@type = N ' logbased ',--default@creation_scrip t = null,--default@pre_creation_cmd = n ' Drop ',--default@vertical_partition = N ' false ',-- default@identityrangemanagementoption = n ' manual ',--default@force_invalidate_snapshot = 1, @ins_cmd = N ' Call sp_MSins_ Dbomyobject ', @del_cmd = n ' Call sp_msdel_dbomyobject ', @upd_cmd = n ' scall sp_msupd_dbomyobject ' go--add view exec sp_ Addarticle @publication = n ' replicationname ', @article = N ' v_myview ', @source_owner = n ' dbo ', @source_object = n ' v_myview ' , @destination_owner = n ' dbo ', @destination_table = N ' v_myview ', @type = N ' view schema only ', @description = null, @creatio N_script = null, @pre_creation_cmd = N ' drop ', @schema_option = 0x0000000008000001, @force_invalidate_snapshot = 1go--Add stored procedure exec sp_addarticle @publication = n ' replicationname ', @article = N ' usp_ MyProc ', @source_owner = n ' dbo ', @source_object = N ' usp_myproc ', @destination_owner = n ' dbo ', @destination_table = N ' usp_m Yproc ', @type = N ' proc schema only ', @description = null, @creation_script = null, @pre_creation_cmd = n ' Drop ', @schema_op tion = 0x0000000008000001, @force_invalidate_snapshot = 1go--add function exec sp_addarticle @publication = N ' Replicationname ', @ Article = n ' f_myfunc ', @source_owner = n ' dbo ', @source_object = N ' f_myfunc ', @destination_owner = n ' dbo ', @destination_tab Le = N ' f_myfunc ', @type = N ' func schema only ', @description = null, @creation_script = null, @pre_creation_cmd = n ' Drop ', @schema_option = 0x0000000008000001, @force_invalidate_snapshot = 1 go/* Adding views/stored procedures/functions is mostly @type different: @type = N ' View schema O Nly ',--View @type = N ' proc schema only ',--stored procedure @type = N ' func schema only ',--function */--the subscription to the new item in its pull subscription is added to the publication exec SP_REFRESHSUBSC Riptions @publication = N ' ReplIcationname ' go--start the Snapshot Agent exec sys.sp_startpublication_snapshot @publication = N ' replicationname ' go/*--remove the Publish project ( i.e. cancel synchronization of an object) exec sp_dropsubscription @publication = n ' replicationname ', @article = N ' MyObject ', @subscriber = n ' All ' goexec sp_droparticle @publication = n ' replicationname ', @article = N ' MyObject ', @force_invalidate_snapshot = 0go*/

Using scripts to add a publication for an object in SQL Server transactional replication

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.