This question already has answers here:
C# - How to I get the MS_Description field from a table schema?
                                
                                    (4个答案)
                                
                        
                                4年前关闭。
            
                    
我只想获取表的MS_Description

现在,我仅将其用于列:

select
    sc.name,
    sep.value [Description]
from sys.tables st
inner join sys.columns sc on st.object_id = sc.object_id
left join sys.extended_properties sep on st.object_id = sep.major_id
                                     and sc.column_id = sep.minor_id
                                     and sep.name = 'MS_Description'
where st.name =@TableName


我那里也有@TableName作为参数
谢谢

最佳答案

试试看-基本上使用minor_id = 0来获取表的描述(没有任何列):

SELECT
    t.Name,
    sep.*
FROM
    sys.tables t
INNER JOIN
    sys.extended_properties sep ON t.object_id = sep.major_id
where
    sep.Name = 'MS_Description'
    AND sep.minor_id = 0    -- not any column - but the table's description

关于c# - SQL Server中的GET表描述,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31652844/

10-13 09:45