Export (0) Print
Expand All

Scripting

Scripting in SMO is controlled by the Scripter object and its child objects, or the Script method on individual objects. The Scripter object controls the mapping out of dependency relationships for objects on an instance of Microsoft SQL Server.

Advanced scripting by using the Scripter object and its child objects is a three phase process:

  1. Discovery
  2. List generation
  3. Script generation

The discovery phase uses the DependencyWalker object. Given an URN list of objects, the DiscoverDependencies method of the DependencyWalker object returns a DependencyTree object for the objects in the URN list. The Boolean fParents parameter is used to select whether the parents or the children of the specified object are to be discovered. The dependency tree can be modified at this stage.

In the list generation phase, the tree is passed in and the resulting list is returned. This object list is in scripting order and can be manipulated.

The list generation phases use the WalkDependencies method to return a DependencyTree. The DependencyTree can be modified at this stage.

In the third and final phase, a script is generated with the specified list and scripting options. The result is returned as a StringCollection system object. In this phase the dependent object names are then extracted from the Items collection of the DependencyTree object and properties such as NumberOfSiblings and FirstChild.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft