SMO Scripter Object in .NET 2.0 Whidbey with Sql Server

I've been finishing up working with the Scripter object in SMO included with .NET 2.0 Whidbey.  There isn't much documentation on it at this time, but it seems to be fairly simple to use.  Here is how I used:

  • Create an array of type SqlSmoObject.
  • Create an object of type StringCollection.
  • Create an object of type Microsoft.SqlServer.Smo.Scripter.
  • Create, define, and set the properties on all your Smo objects that you want to create in Sql Server.
  • Add the Smo objects created in the previous step to the array of SqlSmoObject.
  • Call the Script() method on the scripter object passing the array of SqlSmoObjects.  Pass the returned value to the StringCollection.

Congratulations, you now have a StringCollection of the objects that were created, so you can keep all of the scripting output.  Yippeee


No Comments