SQL Server 2005数据库比较 [英] SQL Server 2005 database comparison

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

问题描述

我正在开发一个数据集中化项目。我必须将数据从两个数据库传输到第三个新创建的主数据库。现有数据库拥有相同类型的数据,表是相同的等。但在此之前,我需要检查主表从现有的两个数据库是相同的,即列名,数字等在两个数据库中的两个相同的表相同。
例如这两个数据库都有一个称为SROMaster的表。我需要检查来自db1的SROMaster是否将与来自db2的SROMaster保持相同的列。有人能帮我吗?谢谢!

I am working on a project of Data Centralization. I have to transfer data from two databases into a third newly created master database.The existing databases hold the same type of data, the tables are the same etc. But before that, I need to check whether the master tables from the existing two databases are the same i.e. the column names, number etc are same of the two same tables in both the databases. For e.g. Both the databases have a table called SROMaster. I need to check if SROMaster from db1 will hold the same columns as SROMaster from db2. Can someone help me? Thanks!

推荐答案

不确定您使用的平台/语言,但无论如何,要测试某个表是否存在可以使用这个T-SQL来完成这项工作:

Not sure what platform/language you're using - but in any case, to test if a given table exists, you can use this T-SQL to do the job:

SELECT t.*
FROM sys.tables t
WHERE t.Name = 'SROMaster'

这将返回一行

一旦你拥有了表,你可以通过使用:

Once you have the table, you can check what columns the table has by using:

SELECT c.*
FROM sys.columns c
INNER JOIN sys.tables t ON c.object_id = t.object_id
WHERE t.Name = 'SROMaster'
ORDER BY c.column_id

将返回一个包含列信息的行数据集 - 比较这两个列表,看看两个表的 SROMaster 表中是否有相同的列。

You'll get back a data set of rows with information about the columns - compare those two lists you're getting to see if you have the same columns in both table's SROMaster table.

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

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