SELECT field name = a.name, type = b.name, field specifies = ISNULL (G. [ Value ] , '' ), is null = Case When a.isnullable = . 1 the then . 1 the else 0 End , whether self-energizing = Case When the COLUMNPROPERTY (a.id, a.name, ' IsIdentity ' ) = . 1 the then . 1 the else 0 End , the primary key = Case When exists(SELECT 1 FROM sysobjects where xtype='PK' and name in ( SELECT name FROM sysindexes WHERE indid in(SELECT indid FROM sysindexkeys WHERE id=a.id AND colid=a.colid)))
then '√' else 'X' end
FROM syscolumns a left join systypes b on a.xusertype=b.xusertype inner join sysobjects d on a.id=d.id and d.xtype in('U','V') and d.name<>'dtproperties' left join syscomments e on a.cdefault=e.id left join sys.extended_properties g on a.id=g.major_id and a.colid=g.minor_id left join sys.extended_properties f on d.id=f.major_id and f.minor_id=0 where d.name='表名' order by a.id,a.colorder