sql server如何檢視欄位註釋?

suyu_yuan發表於2016-10-18



sql如下:

SELECT  A.name AS table_name, B.name AS column_name, C.value AS column_description 
FROM sys.tables A  
INNER JOIN sys.columns B ON B.object_id = A.object_id  
LEFT JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column_id 
WHERE A.name = 't_dept'
;


或者:

select * from sys.extended_properties
where major_id=66815300

其中66815300為t_dept表在資料庫中的object_id

注意:此處只顯示 有註釋的欄位。





相關文章