Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 Development Tools
 Other Development Tools
 What's wrong with my SMO C# tiny program?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 08/14/2012 :  12:06:30  Show Profile  Reply with Quote
I want to script SQL Server objects programmatically [say, delete (DROP) all FKs, then change keys, and restore (CREATE) FKs] with SMO Scripter class.

I found [url=]an article on the Web[/url], but...
Please see [url=]the image[/url] and help me to compile ~20 line long C# program.
I am not a rookie. No.

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 08/14/2012 :  13:28:08  Show Profile  Reply with Quote
Add a
using Microsoft.SqlServer.Management.Sdk.Sfc;

or use
scripter.Script(new Microsoft.SqlServer.Management.Sdk.Sfc.Urn[] { db.Urn });
Go to Top of Page

Starting Member

2 Posts

Posted - 08/15/2012 :  08:51:54  Show Profile  Reply with Quote
Thanks, sunitadeck. It works. Something seems to change since SQL Server 2005.
Case closed.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000