SQL语句显示表结构

来源:互联网 发布:js 取radio的值 编辑:程序博客网 时间:2024/05/18 13:05
select 字段名=a.name,序号=a.colorder,主键=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 indid = a.id and colid = a.colid)))then  '√' else '' end,数据库中类型=b.name,类型=case when b.name='char' orb.name='nchar' orb.name='nvarchar' orb.name='text' orb.name='ntext' then 'string'when b.name='int' orb.name='smallint' orb.name='tinyint' then 'int'whenb.name=''then 'DateTime'when b.name='money' orb.name='decimal'then 'decimal'whenb.name='bit'then 'bool'else b.name end,允许空=case when a.isnullable=1 then '√'else   ''   end,说明字段=ISNULL(g.[value],'') from syscolumns aleft join systypes b on a.xtype=b.xtypeinner join sysobjects d on a.id = d.id and d.xtype='U' and a.name<>'1jieguo'left join sys.extended_properties g on a.id=g.major_id and a.colid=g.minor_idleft join sys.extended_properties f on d.id = f.major_id and f.minor_id=0where d.name='subject'order by a.id,a.colorde

原创粉丝点击