简体   繁体   中英

SQL Server - How to Copy a Stored Procedure to Another Database

I have a stored procedure with the exact same path on multiple servers (live, development and test) and I would like to modify/alter it simultaneously. I was thinking this would happen via altering one and then copying that and overwriting it over the other two servers.

Would this be easily achieved?

  1. If you can connect to all the environments from a single SSMS (unlikely in many companies because of security), you can register all 3 SQL Server instances in a single group and execute the same script on all instances simultaneously (refer to: https://msdn.microsoft.com/en-us/library/bb964743.aspx )

  2. You can script out your stored procedure and use SQLCMD tool to execute it from file. Again, if you can connect to all instances from a single server, you can just duplicate the command in the script, but connect to multiple instances ie just use 3 SQLCMD lines

You can use any schema compare tool, Such as Red Gate SQL Compare

Also check alternative tools to Red Gate: Here

Also youo can check this opensource tool: Open DBdiff

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM