How to: Script Replication Objects (SQL Server Management Studio)
Script replication objects from the replication wizards or from the Replication folder in Microsoft SQL Server Management Studio. If you script from the wizards, you can choose to create objects and script them, or you can choose only to script them.
Security Note |
---|
All passwords are scripted as NULL. When possible, prompt users to enter security credentials at runtime. If you store credentials in a script file, you must secure the file to prevent unauthorized access. |
For more information about using the replication wizards, see:
To script an object from a replication wizard
On the Wizard Actions page of a wizard, select the check box appropriate for the wizard:
Generate a script file with steps to create a publication
Generate a script file with steps to create the subscription(s)
Generate a script file with steps to configure distribution
Specify options on the Script File Properties page.
Complete the wizard.
To script an object from Management Studio
Connect to the Distributor, Publisher, or Subscriber in Management Studio, and then expand the server node.
Expand the Replication folder, and then expand the Local Publications folder or the Local Subscriptions folder.
Right-click a publication or subscription, and then click Generate Scripts.
Specify options in the Generate SQL Script - <ReplicationObject> dialog box.
Click Script to File.
Enter a file name in the Script File Location dialog box, and then click Save. A status message is displayed.
Click OK, and then click Close.
To script multiple objects from Management Studio
Connect to the Distributor, Publisher, or Subscriber in Management Studio, and then expand the server node.
Right-click the Replication folder, and then click Generate Scripts.
Specify options in the Generate SQL Script dialog box.
Click Script to File.
Enter a file name in the Script File Location dialog box, and then click Save. A status message is displayed.
Click OK, and then click Close.