更新时间:2023-02-03 23:07:37
您可以使用 SMO 框架.
可以通过 PowerShell 来免费/轻松实现.
我有一个脚本可以做到这一点 - 它为 SQL 对象生成脚本,包括存储过程,并在目标服务器上执行创建脚本.
I have a script that does just this - it generates the scripts for SQL objects, including Stored Procs, and executes the creation scripts on the target server.
当安全问题不允许链接服务器但您需要在多个服务器之间保持某些资源同步时,这是一种方便的解决方法.
It's a handy workaround when security concerns don't allow linked servers but you need to keep certain resources in sync across multiple servers.
如果您只关心过程,那么检查源和目标数据库上的 sys.sql_modules
并通过 definition
该视图中的字段.
If all you care about are the procs, it should be fairly straightforward to check sys.sql_modules
on your source and target DBs and execute any that don't exist in the target via the definition
field in that view.