Acquiring description data table column value added illustrated as MS SQL Field

Preceded wrote " MS SQL add a description for the field " https://www.cnblogs.com/insus/p/12106589.html

Now, we get describe values ​​of these fields.

Let's look a SELECT statement:

 

SELECT * FROM sys.extended_properties
GO
Source Code

 

As a SQL statement, although the value obtained as described, but we do not know which one is a table, and which fields.

Therefore, the system must use another object associated with the query:

 

SELECT t.[name] AS [Table_Name],c.[name] AS [Column_Name],e.[value] AS [Column_Description]
FROM sys.tables t
INNER JOIN sys.columns c ON(t.[object_id] = c.[object_id])
LEFT JOIN sys.extended_properties e ON (t.[object_id] = e.[major_id] AND c.[column_id] = e.[minor_id] AND e.[name] = 'MS_Description')

GO
Source Code

 

Guess you like

Origin www.cnblogs.com/insus/p/12149214.html