【记录】sql2008 字段描述查询

SELECT
字段名 = CONVERT (VARCHAR(100), a.name),
表名 = CONVERT (VARCHAR(50), d.name),
类型 = CONVERT (VARCHAR(50), b.name),
库名 = '库名',
字段说明 = CONVERT (
VARCHAR (50),
isnull(g.[value], '')
)
FROM
dbo.syscolumns a
LEFT JOIN dbo.systypes b ON a.xusertype = b.xusertype
INNER JOIN dbo.sysobjects d ON a.id = d.id
AND d.xtype = 'U'
AND d.name <> 'dtproperties'
LEFT JOIN dbo.syscomments e ON a.cdefault = e.id
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 = '表名'

你可能感兴趣的:(数据库,sql,select)