Created
February 21, 2017 00:26
-
-
Save stephenhardy/ee2b0c1f31b26896179133dff12f7fcf to your computer and use it in GitHub Desktop.
MSSQL Server Find empty tables
This file contains 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 | |
t.name table_name | |
from | |
sys.tables t | |
join sys.schemas s on (t.schema_id = s.schema_id) | |
join sys.partitions p on (t.object_id = p.object_id) | |
where p.index_id in (0,1) | |
group by t.name,s.name | |
having sum(p.rows) = 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment