Created
February 20, 2012 13:41
-
-
Save keithbloom/1869246 to your computer and use it in GitHub Desktop.
Using Extended Properties to limit the call to sp_msforeachtable
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
SELECT s.name [Schema], t.name [Table], | |
CAST(Value AS nvarchar(500)) AS [MS_Description] | |
FROM sys.extended_properties AS ep | |
JOIN sys.tables t | |
on ep.major_id = t.object_id | |
join sys.schemas s | |
on s.schema_id = t.schema_id | |
WHERE ep.name = N'MS_Description' AND ep.minor_id = 0 | |
and LOWER(CAST(Value AS nvarchar(500))) like '%lookup%' | |
order by s.name, t.name |
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
USE AdventureWorks | |
GO | |
EXEC sp_msforeachtable @command1 = 'EXECUTE sp_spaceused [?];' | |
,@whereand = 'AND o.id in ( | |
SELECT ep.major_id | |
FROM sys.extended_properties AS ep | |
WHERE LOWER(CAST(Value AS nvarchar(500))) LIKE ''%lookup%'' | |
AND ep.name = N''MS_Description'' | |
AND ep.minor_id = 0)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment