locked
stored procedure RRS feed

  • Question

  • Hi,

    How to copy the stored procedures from one database to other database in the same server and in different server?

    Monday, December 9, 2013 4:44 PM

Answers

  • Hi,

    How to copy the stored procedures from one database to other database in the same server and in different server?

    hello,

    you can do this by taking script of SP and running on other server see below link

    http://stackoverflow.com/questions/10703424/sql-server-copy-stored-procedures-from-one-db-to-another

    Make sure  database tables  and logins exist in destination server


    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

    • Proposed as answer by pituachMVP Monday, December 9, 2013 5:06 PM
    • Marked as answer by Ch. Rajen Singh Tuesday, December 17, 2013 1:53 AM
    Monday, December 9, 2013 4:48 PM
  • Hi Surya,

    You can use the generate script wizard to script out the procedure definition to a .sql file and then execute the .sql file on other server. Ensure to set the user [dbname] command correctly on top of the .sql file.

    You can also use the below script to bring out the procedure definition :

    use [dbname]

    exec sp_helptext'procedurename'

    The out put of the above script is the procedure definition which you can just copy and paste it on a new query window in the context of the DB where the procedure needs to be created and finally execute it.


    Thanks and Regards Alankar Chakravorty MCITP Database Administrator SQL Server 2008 MCITP Database Administrator SQL Server 2005

    • Proposed as answer by pituachMVP Monday, December 9, 2013 5:06 PM
    • Marked as answer by Ch. Rajen Singh Tuesday, December 17, 2013 1:53 AM
    Monday, December 9, 2013 4:57 PM

All replies

  • Hi,

    How to copy the stored procedures from one database to other database in the same server and in different server?

    hello,

    you can do this by taking script of SP and running on other server see below link

    http://stackoverflow.com/questions/10703424/sql-server-copy-stored-procedures-from-one-db-to-another

    Make sure  database tables  and logins exist in destination server


    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

    • Proposed as answer by pituachMVP Monday, December 9, 2013 5:06 PM
    • Marked as answer by Ch. Rajen Singh Tuesday, December 17, 2013 1:53 AM
    Monday, December 9, 2013 4:48 PM
  • Hi Surya,

    You can use the generate script wizard to script out the procedure definition to a .sql file and then execute the .sql file on other server. Ensure to set the user [dbname] command correctly on top of the .sql file.

    You can also use the below script to bring out the procedure definition :

    use [dbname]

    exec sp_helptext'procedurename'

    The out put of the above script is the procedure definition which you can just copy and paste it on a new query window in the context of the DB where the procedure needs to be created and finally execute it.


    Thanks and Regards Alankar Chakravorty MCITP Database Administrator SQL Server 2008 MCITP Database Administrator SQL Server 2005

    • Proposed as answer by pituachMVP Monday, December 9, 2013 5:06 PM
    • Marked as answer by Ch. Rajen Singh Tuesday, December 17, 2013 1:53 AM
    Monday, December 9, 2013 4:57 PM