4

Is there an easy way to copy all stored procedures from one database to another? I have SQL Management Studio installed.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
stringo0
  • 2,720
  • 7
  • 38
  • 52

2 Answers2

6

In SQL 2005 and 2008 management: Right click on the database, choose tasks -> generate scripts. You should be able to follow the directions in the wizard from there.

In Sql 2000 you can actually just select the procedures you want to copy, ctrl+c to copy them, then paste them into a new query window for the other DB and run it.

Brian Duncan
  • 480
  • 3
  • 12
  • actually in SQL 2000, Enterprise manager will do this for you, you start off with All Tasks - Export Data and then select copy objects and data – PatFromCanada Mar 22 '13 at 16:31
1

You can script objects out with SQL Management Studio by right clicking the database name and clicking script objects(or something like that I'm not on my Windows machine right now to check). You can select to do just the stored procs and select to have all the output go to one file instead of 1 file per an object. Once you have them in one file you can run that file against your database.

Also look into Red Gate Software's tool called SQL Compare http://www.red-gate.com/products/SQL_Compare/index.htm It's not free but does have a free trial.

Kuberchaun
  • 29,160
  • 7
  • 51
  • 59