在 SQL Server 中提取表元数据:描述、字段和数据类型
问题陈述:
数据库用户经常需要有关其 SQL Server 表的详细信息,包括表描述、字段
解决方案:
为了全面提取此类元数据,以下查询利用各种系统表和扩展属性:
SELECT u.name + '.' + t.name AS [table], td.value AS [table_desc], c.name AS [column], cd.value AS [column_desc] FROM sysobjects t INNER JOIN sysusers u ON u.uid = t.uid LEFT OUTER JOIN sys.extended_properties td ON td.major_id = t.id AND td.minor_id = 0 AND td.name = 'MS_Description' INNER JOIN syscolumns c ON c.id = t.id LEFT OUTER JOIN sys.extended_properties cd ON cd.major_id = c.id AND cd.minor_id = c.colid AND cd.name = 'MS_Description' WHERE t.type = 'u' ORDER BY t.name, c.colorder
说明:
注意:
以上是如何提取 SQL Server 表元数据:描述、字段和数据类型?的详细内容。更多信息请关注PHP中文网其他相关文章!