Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
SMO Scripter Object in .NET 2.0 Whidbey with Sql Server - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on .NET, Sql, ASP.NET, and other crazy shenanigans

News

Personal Blog

Work Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

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

Wally

Comments

TrackBack said:

# December 29, 2004 9:46 PM

Weblog said:

To follow up on the SMO Scripter() object, many of the SMO objects, like Table(), Column(), Index(),...

# October 3, 2006 5:30 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)