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

 All Forums
 Development Tools
 Other Development Tools
 What's wrong with my SMO C# tiny program?

Author  Topic 

m.i.d.
Starting Member

2 Posts

Posted - 2012-08-14 : 12:06:30
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=http://www.yaldex.com/sql_server/progsqlsvr-CHP-12-SECT-1.html]an article on the Web[/url], but...
Please see [url=https://dl.dropbox.com/u/60064807/SMOQuestion.jpg]the image[/url] and help me to compile ~20 line long C# program.
Thanks.
I am not a rookie. No.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-08-14 : 13:28:08
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

m.i.d.
Starting Member

2 Posts

Posted - 2012-08-15 : 08:51:54
Thanks, sunitadeck. It works. Something seems to change since SQL Server 2005.
Case closed.
Go to Top of Page
   

- Advertisement -