Friday, March 23, 2012

How to change default script generation options in SQL 2005 tools or VS 2005

Ok, this has been driving me crazy in both SQL Management Studio and VS 2005 Server Explorer. How do you change the default script generation options?

When I right-click a stored procedure, table, etc. in the SQL Management Studio's Object Explorer, or in the VS 2005 Server Explorer and choose to generate a create script for that object it does not prompt me for any scripting options (like do I want to script dependant objects (where my answer is a resounding NO! but the default that ships with the tools is yes)).

I wouldn't mind complaining that I should be able to select multiple items in these tools and generate scripts for all selected items all at once. This doesn't seem to happen in Management studio at all, and if you do this in VS 2005's server explorer it always throws all your selected objects into one big ugly script file. I know that is more a vs issue than a SQL one, but if anyone has an answer to that I'd appreciate it.

In SQL management studio, in the Generate Scripts Wizard (the only way to gen more than one object at a time) is there a way to 1) make it create different files for each object I script and 2) is there, PLEASE, a way to stop the generated scripts for procs/functions from generating the IF statement to check to see if the object exists before the create statement? The reason for this is that I really do not want my create statement executed via the EXEC command as a string. You loose all your color coding, and if you generated in VS 2005 the editor has really annoying behavior when you use the CTRL + Arrow keys inside a string and you also loose the ability to edit the SQL block using the GUI query builder.

Anyway, any help with this would be appreciated.

Thanks

Hi, did you ever get a solution to this?

(I've come across the same problem)

Thanks,

Steve|||

There is an options page in the RTM version of the Generate Scripts Wizard in SQL Server Management Studio. There is an option for "Generate Script for Dependent Objects", and the default is "False."

There is also an option for "Include If NOT EXISTS", but the default there is "True." Setting the option to "False" makes the wizard omit the check.

The Generate Scripts Wizard can copy the generated SQL to a single file, the clipboard, or to a new SQL editor instance in SSMS.

|||Hi,

My specific problem was the fact that there was no options page if you chose to script the object by right-clicking the object in SQL Mgmt Studio.

I know if you right-click the database, that does open a wizard window and lets you change options but not if you right-click the object, or use VS2005 to script the object.

In the old VS2003, when you dragged an object from the Server Explorer to the Solution Explorer it would pop-up the script wizard window, but now it doesn't and seems to use it's own settings (which I can't change!)

Thanks,

Steve|||

You're right, the script menu items in SSMS for the objects themselves have no configurable options. I've added this as a feature request for a future release of SQL Server Management Studio.

|||Excellent, thanks!

Stevesql

No comments:

Post a Comment