尝试这个:
SELECT
s.[name] AS [schema_name]
, t.[name] AS [table_name]
, c.[name] AS [column_name]
, x.[value] AS [MS_Description]
FROM [sys].[schemas] AS s
INNER JOIN [sys].[tables] AS t
ON s.[schema_id] = t.[schema_id]
INNER JOIN [sys].[columns] AS c
ON t.[object_id] = c.[object_id]
LEFT OUTER JOIN [sys].[extended_properties] AS x
ON t.[object_id] = x.[major_id]
AND c.[column_id] = x.[minor_id]
AND x.[name] = 'MS_Description'
WHERE
t.[name] = 'your_table_name'
AND s.[name] = 'your_schema_name';
样本结果集:
+-------------+------------+----------------+-------------------------+
| schema_name | table_name | column_name | MS_Description |
+-------------+------------+----------------+-------------------------+
| dbo | tblClients | pk_ClientID | NULL |
| dbo | tblClients | ClientName | Client's business name. |
| dbo | tblClients | PrimaryContact | NULL |
| dbo | tblClients | Addr | NULL |
| dbo | tblClients | Addr2 | NULL |
| dbo | tblClients | Addr3 | NULL |
| dbo | tblClients | City | NULL |
| dbo | tblClients | State | NULL |
| dbo | tblClients | Zipcode | NULL |
| dbo | tblClients | Phone | NULL |
+-------------+------------+----------------+-------------------------+