Scripting a Replication
I don't know too much about SQL Server transactional replication, but am I correct that once we have manually created all the articles we want involved in the replication, we can have that replicati开发者_开发问答on 'definition' scripted so that we can either disable the replication or enable it after it's been disable, simply by executing the T-SQL script?
If you right-click on the publication in SSMS, there's a "Generate scripts..." option. Be careful though: it does some things that while technically correct are non-intuitive and likely to not do what you want. One that comes to the top of my head is the '@sync_type' parameter to sp_addsubscription. I've always seen it scripted out as "replication support only" which is likely not what you want. I guess what I'm trying to say is to review the script before you run it to make sure that it does what you want it to do.
A simple T-SQL script for creation a publication and its associated subscription: http://sqlhint.com/sqlserver/how-to/create-transactional-replication-tsql-script
An option to deactivate replication is to start/stop replication agents.
精彩评论