use [数据库名]
SELECT a.[name] as '字段名',a.length '长度',c.[name] '类型',e.value as '字段说明' FROM syscolumns ?a? left ? join ? ?systypes ? ?b ? on ? ? ?a.xusertype=b.xusertype? left ? ? join ? ? systypes ? ? c ? ? on ? ? ?a.xtype = c.xusertype? inner ? join ? sysobjects ?d ? on ? ? ?a.id=d.id ? ? and ? d.xtype='U'? left join sys.extended_properties e on a.id = e.major_id and a.colid = e.minor_id and e.name='MS_Description' where d.name='表名'
如:
use [erpdb]
SELECT a.[name] as '字段名',a.length '长度',c.[name] '类型',e.value as '字段说明' FROM syscolumns ?a? left ? join ? ?systypes ? ?b ? on ? ? ?a.xusertype=b.xusertype? left ? ? join ? ? systypes ? ? c ? ? on ? ? ?a.xtype = c.xusertype? inner ? join ? sysobjects ?d ? on ? ? ?a.id=d.id ? ? and ? d.xtype='U'? left join sys.extended_properties e on a.id = e.major_id and a.colid = e.minor_id and e.name='MS_Description' where d.name='TICommission' ?
|