|
昨天被数据库的不同步给弄郁闷了,开发和测试的库不是一个,开发的这个库,存储过程经常更新。有时候甚至表结构都有些变化。 这就导致了很多问题。一时半会还不知道具体是什么问题,搞得老子很狼狈,一时性起,想写一个程序来比较两个库的不同,方便测试和实施。 今天上午,边开会边写,中午的时候通过测试.
主要是两个SQL语句: 查询库中表和视图结构和列属性不同的SQL如下:
select A. [name] as TableName, B. [name] as Colname, B.xtype, B.xusertype, B.length, B.colid, B.cdefault, B.domain, B.number, B.offset, B.status, B.type, B.usertype, B.prec, B.scale, B.iscomputed, B.isoutparam, B.isnullable, C.COLUMN_DEFAULT, dbo.fnIsColumnPrimaryKey(B. [ID], B. [name]) as PKey from sysobjects A, syscolumns B, INFORMATION_SCHEMA .COLUMNS C where a. id = B. id and A.xtype in ('u', 'v') and A. Name = C.TABLE_NAME and B. Name = C.COLUMN_NA [1] [2] [3] [4] 下一页 更多精彩:学习网->http://www.haohao888.com.cn 网络编程->http://www.51wlpc.com 电脑设备->http://www.xpmaster.cn
|