Microsoft® SQL Server® 2012 Bible

(Ben Green) #1

794


Part V: Enterprise Data Management


FIGURE 30-3
SMO scripting objects.

Scripter

Server

Options

ScriptDrops

WithDependencies

FileName

IncludeHeaders

AppendToFile

ToFileOnly

ClusteredIndexes

Indexes

DriAll

Script

The Server property enables the Scripter object to connect to the server. The remaining
properties needing to be set are in the Scripter Options collection.

The ScriptDrops property specifi es whether the script consists of drops for the objects or
creates for the objects. If this property is set to True, the script contains a DROP statement
for each object (within an IF condition to ensure that it exists), but a False value causes
the scripter to generate the CREATE statement for each object. The WithDependencies
property, if True, causes the objects to be scripted in an order that respects the depen-
dency of one scripted object on another. The FileName property contains the full path
of the resultant script fi le. The IncludeHeaders property, when True, includes a com-
ment indicating the name of the object and when the object was created in the script. The
AppendToFile property appends the script to the end of an existing fi le if True, and
overwrites the fi le if False.

c30.indd 794c30.indd 794 7/31/2012 9:46:23 AM7/31/2012 9:46:23 AM


http://www.it-ebooks.info
Free download pdf