Microsoft SQL Server 2008 R2 : Scripting Replication

Earlier, it was strongly suggested that you generate
SQL scripts for all that you do because going through wizards every time
you have to configure replication is a difficult way to run a
production environment. In the example in the preceding section, you
always chose to generate these scripts as you built up the replication
configuration. This was only half the scripts needed, however. You must
also generate the breakdown scripts (that is, those that drop and remove
replication components) to remove each component of the replication
topology in case you need to start from scratch or, as an example,
rebuild a subscriber that is completely nonfunctional. As you can see in
Figure 1,
SQL Server Management Studio has a great feature that allows the
complete generation of all aspects of replication topology (including
disabling and removing replication).

Figure 1. A script-generation feature for all replication topology components.

Note

Remember that working
from scripts minimizes the errors you make while supporting your data
replication environments (especially at 3:00 a.m.).

The
following example shows the SQL scripts needed to generate the part of
the data replication configuration you just built with the wizard: