SQLserver查看⽤户表的所有字段信息
select t1.id tabid,t1.name tabname,t2.name colname,t3.name datatype,t2.length
from sysobjects t1,syscolumns t2,systypes t3
pe='U'
and t1.id=t2.id
pe;
更详细的说明:
SELECT
表名 = d.name,
表说明 = isnull(f.value, ''),
字段序号 = a.colorder,
字段名 = a.name,
标识 = case when COLUMNPROPERTY(a.id, a.name, 'IsIdentity')= 1 then 'Y'else '' end,
主键 = case when exists(SELECT 1 FROM sysobjects where xtype = 'PK' and parent_obj = a.id and name in (
SELECT name FROM sysindexes WHERE indid in(SELECT indid FROM sysindexkeys WHERE id = a.id AND colid = a.colid))) then 'Y' else '' end,
isnull的用法类型 = b.name,
最⼤字节数 = a.length,
最⼤长度 = COLUMNPROPERTY(a.id, a.name, 'PRECISION'),
⼩数位数 = isnull(COLUMNPROPERTY(a.id, a.name, 'Scale'), 0),
允许空 = case when a.isnullable = 1 then 'Y'else '' end,
默认值 = , ''),
字段说明 = isnull(g.value, '')
FROM syscolumns a
left join systypes b
on a.xusertype = b.xusertype
inner join sysobjects d
on a.id = d.id pe = 'U' and d.name <> 'dtproperties'
left join syscomments e
on a.cdefault = e.id
left ded_properties g
on a.id = g.major_id lid = g.minor_id
left ded_properties f
on d.id = f.major_id and f.minor_id = 0
order by d.lorder

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。