1 create procedure [dbo].[tbInfo] 2 ( 3 @tbName varchar(50) 4 ) 5 as 6 select 7 表名=case when a.colorder=1 then d.name else '' end, 8 表说明=case when a.colorder=1 then isnull(f.value,'') else '' end, 9 字段序号=a.colorder, 10 字段名=a.name, 11 标识=case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end, 12 主键=case when exists(select 1 from sysobjects where xtype='PK' and name in ( 13 select name from sysindexes where indid in( 14 select indid from sysindexkeys where id = a.id AND colid=a.colid 15 ))) then '√' else '' end, 16 类型=b.name, 17 占用字节数=a.length, 18 长度=COLUMNPROPERTY(a.id,a.name,'PRECISION'), 19 小数位数=isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0), 20 允许空=case when a.isnullable=1 then '√'else '' end, 21 默认值=isnull(e.text,''), 22 字段说明=isnull(g.[value],'') 23 from syscolumns a 24 left join systypes b on a.xtype=b.xusertype 25 inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' 26 left join syscomments e on a.cdefault=e.id 27 28 left join sys.extended_properties g on a.id=g.major_id AND a.colid = g.minor_id 29 left join sys.extended_properties f on d.id=f.major_id and f.minor_id=0 30 where d.name=@tbName --如果只查询指定表,加上此条件 31 order by a.id,a.colorder