Dela via


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 noteSecurity 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

  1. 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

  2. Specify options on the Script File Properties page.

  3. Complete the wizard.

To script an object from Management Studio

  1. Connect to the Distributor, Publisher, or Subscriber in Management Studio, and then expand the server node.

  2. Expand the Replication folder, and then expand the Local Publications folder or the Local Subscriptions folder.

  3. Right-click a publication or subscription, and then click Generate Scripts.

  4. Specify options in the Generate SQL Script - <ReplicationObject> dialog box.

  5. Click Script to File.

  6. Enter a file name in the Script File Location dialog box, and then click Save. A status message is displayed.

  7. Click OK, and then click Close.

To script multiple objects from Management Studio

  1. Connect to the Distributor, Publisher, or Subscriber in Management Studio, and then expand the server node.

  2. Right-click the Replication folder, and then click Generate Scripts.

  3. Specify options in the Generate SQL Script dialog box.

  4. Click Script to File.

  5. Enter a file name in the Script File Location dialog box, and then click Save. A status message is displayed.

  6. Click OK, and then click Close.

See Also

Concepts