Discussion Locked

SQL:Copy Sored Proc to a new db?

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Re: MS SQL Svr 7
Is there a quick & easy way to copy SQL stored procs from one database to another database and then compile it in the new database using T\SQL code? Other than getting the text from sp_helptext and executing it in the new database,I am at a loss.

3 replies

by chrandrob

Right click on the stored procedure, go to All Tasks, click on Generate SQL Scripts. The ensuing popup window will allow you to set a variety of options for the script and then either save the script to a sql query file or copy it to the clipboard.
Then you can run the script in Query Analyzer or Enterprise Manager on as many databases as you want to create the sp there. Running the generated script will create the sp, not execute it.

This discussion is closed to new replies.