Scripting Replication
You can script commonly performed replication functions such as configuring publishing and distribution, and creating or deleting publications and subscriptions. After you configure or create a replication component, you can automate the creation of a script by using SQL Server Enterprise Manager.
The script contains the Transact-SQL system stored procedures necessary to implement the replication component. Composed primarily of a series of stored procedures, you can view, execute, and/or modify and run the script using SQL Query Analyzer or osql.
You can choose to script creation or deletion of one or a combination of the following:
- Distributor properties
- Publications and push subscriptions
- Pull subscriptions
If you need to delete multiple push subscriptions or a mix of push and pull subscriptions, you can automate the process by creating a script to delete the publication. All subscriptions to the publication will be deleted with the publication. If you are deleting pull subscriptions, you can generate a script that deletes one or more pull subscriptions without deleting the publication.
Because Northwind Traders has more than 50 sales representatives in different territories, it would be time-consuming to create the different subscriptions needed at each Subscriber. Instead, the replication administrator can set up the necessary merge publications (with static or dynamic partitions based on the sales representative or their territory), and then create a pull subscription, generate a script based on that pull subscription, and then run that script at multiple Subscribers to generate the necessary pull subscriptions.
To script replication