跨多个数据库比较存储过程 (SQL Server) [英] Compare stored procedures across multiple databases (SQL Server)

查看:56
本文介绍了跨多个数据库比较存储过程 (SQL Server)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL 大师 --

我们的架构由多个客户数据库组成,共同的代码库.当我们部署数据库更改时,脚本必须针对每个数据库运行.

Our architecture consists of multiple customer databases to a common codebase. When we deploy database changes, the scripts must be run agianst each database.

由于部署问题,有时我们的存储过程彼此不同步.我想创建一个脚本来返回这些不匹配的过程,以确保我们在部署后同步了我们的数据库副本.

Because of deployment issues, there have come times when our stored procedures became out of sync with one another. I would like to create a script to return these mimatched procedures to ensure that we have sync'd copies of our databases after deployment.

是否可以通过脚本查看两个数据库之间的所有过程并返回不匹配项来比较两个或多个数据库?

Is it possible to compare two or more databases, by having a script look at all the procedures between two databases, and return the mismatches?

效果如下:

DATABASE_1 | DATABASE_2  | MISMATCHED_PROCEDURE | DATABASE_1_MODIFY_DATE | DATABASE_2_MODIFY_DATE
Customer_1 | Customer_2  | sp_get_names         | 1/1/2010               | 1/2/2010
Customer_1 | Customer_2  | sp_add_person        | 1/5/2010               | 1/6/2010

作为一个奖励,是否可以通过将最新脚本应用于过时脚本来让脚本自动同步数据库?

As a bonus, would it be possible to have the script automatically sync the databases by applying the newest script to the out-of-date script?

非常感谢!

推荐答案

有很多工具可以做到这一点.最好的之一是 Red-Gate SQL 比较.另一个非常好的替代方法是使用 Visual Studio Database Professional 来管理您的数据库架构.除此之外,它会做非常好的模式比较.

There are many tools to do this. One of the best is Red-Gate SQL Compare. Another very good alternative is to use Visual Studio Database Professional to manage your database schema. Among other things, it will do very nice schema compares.

这篇关于跨多个数据库比较存储过程 (SQL Server)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆