SELECT t.[name] AS 表名,c.AS 字段名,cast(ep.value] as varchar(100)) AS 字段说明] FROM sys.tables AS t INNER JOIN sys.columns AS c ON t.object_id = c.object_id LEFT JOIN sys.extended_properties AS ep ON ep.major_id AND ep.minor_id = c.column_id WHERE ep.class =1 AND t.name='TableName'
快速查看表结构
END AS 表名,col.colorder AS 序号,col.name AS 列名,ISNULL(ep.],0)">'') AS 列说明,t.name AS 数据类型,col.length AS 长度,255)">ISNULL(COLUMNPROPERTY(col.id,col.name,0)">Scale'),0) AS 小数位数,255)">WHEN IsIdentity') THEN √'
''
AS 标识,255)">WHEN EXISTS ( SELECT 1
FROM dbo.sysindexes si
JOIN dbo.sysindexkeys sik ON si.id = sik.id
AND si.indid = sik.indid
JOIN dbo.syscolumns sc ON sc.id AND sc.colid = sik.colid
JOIN dbo.sysobjects so ON so.name = si.name
AND so.xtype = PK'
WHERE sc.id = col.id
= col.colid ) AS 主键,255)">WHEN col.isnullable AS 允许空,255)">ISNULL(comm.text,255)">AS 默认值
FROM dbo.syscolumns col
LEFT JOIN dbo.systypes t ON col.xtype = t.xusertype
inner JOIN dbo.sysobjects obj ON col.id = obj.id
AND obj.xtype U'
AND obj.status >= 0
JOIN dbo.syscomments comm ON col.cdefault = comm.id
JOIN sys.extended_properties ep = ep.major_id
AND col.colid = ep.minor_id
AND ep.name MS_Description'
JOIN sys.extended_properties epTwo ON obj.id = epTwo.major_id
AND epTwo.minor_id 0
AND epTwo.name '
WHERE obj.name '表名
ORDER BY col.colorder ;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。