Sql中获取表结构(字段名称,类型,长度,说明)

Sql中获取表结构(字段名称,类型,长度,说明)
SELECT
TableName = OBJECT_NAME(c.object_id),
ColumnsName = c.name,
Description = ex.value,
ColumnType=t.name,
Length=c.max_length
FROM
sys.columns c
LEFT OUTER JOIN
sys.extended_properties ex
ON
ex.major_id = c.object_id
AND ex.minor_id = c.column_id
AND ex.name = 'MS_Description'
left outer join
systypes t
on c.system_type_id=t.xtype
WHERE
OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0
AND OBJECT_NAME(c.object_id) ='user_Weight'
And t.name <>'sysname'

 

posted @ 2019-03-07 11:21  放飞梦想  阅读(910)  评论(0编辑  收藏  举报