Skip to content

Instantly share code, notes, and snippets.

@stephenhardy
Created February 21, 2017 00:26
Show Gist options
  • Save stephenhardy/ee2b0c1f31b26896179133dff12f7fcf to your computer and use it in GitHub Desktop.
Save stephenhardy/ee2b0c1f31b26896179133dff12f7fcf to your computer and use it in GitHub Desktop.
MSSQL Server Find empty tables
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