SQL Server 2005 Scripting

  • I've been using 2005 for almost a year and now I find there's something that is doesn't do nearly as easily or intuitively as 2000. I want to create single file drop-and-create scripts for each stored procedure that I've modified for a client. In 2000 this was very easy to do with a simple right-click and select the objects to be scripted. I've found I can select multiple objects from the summary window, but I can see no option to script both drop and create into a single file per object.

    I feel like a complete idiot here. I've been doing SQL Server for years and now can't figure out something that should be very simple.

    Todd Fifield

  • Right Click the database --> tasks --> generate scripts --> you can choose to drop create any/all objects and set a bunch of options including drop existing and check for existence etc..

  • You can do this through Management Studio very quickly. Right clicking the object brings up a menu with "Script Stored Procedure as" and then another menu that has choices like CREATE, ALTER, DROP, EXECUTE. Each of these includes a "To" drop down that includes "New Query Editor Window", File, Clipboard. I use it all the time. You can set options for how the scripts are generated in the Tools, Options, Scripting window.

    Works great.

    One trick, to select mulitple scripts, you can't select them in the Object Explorer window, but if you have the Object Explorer Details window open you can do a multi-select there.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thanks Grant. I had no idea you could script multiple objects from Object Explorer details window. 😀

  • Thanks guys. This helps some. Is there any way to have each object script in a separate file?

    Todd Fifield

  • To my knowledge, not using this quick way of scripting. If you do an actual export to file you get the option of having a single file or seperate files for database objects.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thanks. I tried it before and didn't notice an option for 1 file per object. Maybe I just missed it. I'll try it again.

    Todd

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply