Created
December 3, 2019 16:28
-
-
Save wbhinton/36ef950c25dd6ec6602e5ac11c8f2004 to your computer and use it in GitHub Desktop.
A simple script to get all the tables and columns in a DB with descriptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This works for T-SQL | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment