项目中常常会遇到查询每个字段在那些表中用,尤其是对新人来接收老项目,项目资料不全会害死人。
以下是查询字段和表的映射关系的sql
SELECT c.[name] AS 字段名, t.[name] AS 表名, cast(ep.[value] as nvarchar(200)) 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 = c.object_id AND ep.minor_id = c.column_id