select a.name, (select value from sys.extended_properties where name='MS_Description' and major_id=id and minor_id=colorder) as Alias, CASE WHEN COLUMNPROPERTY(a.id, a.name, 'IsIdentity') = 1 THEN 1 ELSE 0 END AS 标识, (select b.name from systypes AS b where a.xtype = b.xusertype) 类型, a.length AS 长度 from syscolumns a where id=object_id('U_item')可以用系统的函数syscolumns取得表的各个字段然后对比操作!
ap0405140的方法也是我们现在所采用的方法,具体的代码可以在sql server 2008的示例数据库中查到。 另外,也可以用red gate的SQL Compare工具进行对比;或者建立专门的数据库版本控制(这个维护起来有点麻烦)。
select a.name,
(select value from sys.extended_properties where name='MS_Description' and major_id=id and minor_id=colorder) as Alias,
CASE WHEN COLUMNPROPERTY(a.id, a.name, 'IsIdentity') = 1 THEN 1 ELSE 0 END AS 标识,
(select b.name from systypes AS b where a.xtype = b.xusertype) 类型,
a.length AS 长度
from syscolumns a
where id=object_id('U_item')可以用系统的函数syscolumns取得表的各个字段然后对比操作!
另外,也可以用red gate的SQL Compare工具进行对比;或者建立专门的数据库版本控制(这个维护起来有点麻烦)。