tags:

views:

63

answers:

2

I am using the Microsoft.SqlServer.Management.Smo classes to script out SQL scripts for stored procedures, tables, views etc. I am doing this for putting them in source control.

Instead of the CREATE scripts for stored procedures, how can I get ALTER scripts for them? Is there an setting / option in the ScriptingOptions' properties?

+1  A: 

There seems to be no setting for ALTER scripts. The property with ScriptingOptions.ScriptDrops as true creates the drop statements. The downside to this is that the permissions would have to reassigned.

Closing this question.

hIpPy
I agree - I tried this before and never found a method for scripting out an alter. I ended up resulting to using the ScriptingOptions (http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.scriptingoptions_members.aspx) to specify a check for existence and drop if found.
Bobby B
A: 

Hey hlpPy,
Have a look at DBSourceTools. http://dbsourcetools.codeplex.com
It is a GUI tool to script all objects in a SQL Database to disk, specifically for source-code control of databases.
The back-end uses SMO.

blorkfish