SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

m.i.d.
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=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
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

m.i.d.
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  
 New 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.05 seconds. Powered By: Snitz Forums 2000