比较SQL Server中的数据库模式 [英] Compare database schema in SQL server

查看:99
本文介绍了比较SQL Server中的数据库模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何比较SQL Server中两个数据库的数据库模式?是否有任何查询或存储过程可以找到它?

How to compare the database schema of two databases in SQL server?Is there any query or stored procedure to find it out?

推荐答案

有一些免费和付费工具。



此处 [ ^ ]是一些好工具的列表。



您还可以查看 Visual Studio 2010中的SQL Server架构比较工具 [ ^ ]。
There are a number of free and paid tools available.

Here[^] is a list of some good tools.

You can also have a look at SQL Server Schema Comparison Tool in Visual Studio 2010[^].


试试这个



http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx [ ^ ]


没有简单的方法可做这使用存储过程或查询。您可以尝试查询包含有关数据库的所有元数据的sys模式。



例如,您可以获取此类存储过程的对象定义



There is no easy way to do this using stored procedure or query. You can try querying sys schema that contains all meta data about database.

For example you can get object definition for stored procedures like this

select OBJECT_SCHEMA_NAME(P.object_id) as [Schema], P.name as [Procedure Name] ,c.text as Procedure_Definition
from sys.procedures P
inner join sys.syscomments C on P.object_id = C.id





使用此查询,您可以连接两个数据库表,并选择database1.sys.syscomments.text不符合database1.sys.syscomments.text


另一种选择是使用第三方工具,如ApexSQL Diff或市场上的任何类似工具。



Using this query you can join two database tables and select those where database1.sys.syscomments.text is not qual to database1.sys.syscomments.text

Another option is to use a third party tool such as ApexSQL Diff or any similar tool on the market.


这篇关于比较SQL Server中的数据库模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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