且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL Server 2005数据库比较

更新时间:2022-11-24 17:16:49

不确定您使用的平台/语言,但无论如何,要测试某个表是否存在可以使用这个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.