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' or
b.name='nchar' or
b.name='nvarchar' or
b.name='text' or
b.name='ntext'
then 'string'
when
b.name='int' or
b.name='smallint' or
b.name='tinyint'
then 'int'
when
b.name=''
then 'DateTime'
when
b.name='money' or
b.name='decimal'
then 'decimal'
when
b.name='bit'
then 'bool'
else b.name
end,
允许空=case when a.isnullable=1 then '√'else '' end,
说明字段=ISNULL(g.[value],'')
from syscolumns a
left join systypes b on a.xtype=b.xtype
inner 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_id
left join sys.extended_properties f on d.id = f.major_id and f.minor_id=0
where d.name='subject'
order by a.id,a.colorde