Skip to content

Instantly share code, notes, and snippets.

@alex-titarenko
Created April 9, 2017 20:38
Show Gist options
  • Save alex-titarenko/3956eba54a79df19c547106d53240276 to your computer and use it in GitHub Desktop.
Save alex-titarenko/3956eba54a79df19c547106d53240276 to your computer and use it in GitHub Desktop.
Get useful information about database tables
declare @t table (name varchar (255),
[rows] varchar(255),
reserved varchar(255),
data varchar (255),
index_size varchar( 255),
unused varchar(255 ))
delete from @t
insert into @t exec sp_MSforeachtable @command1 ='EXEC sp_spaceused ''?''',@whereand= 'or OBJECTPROPERTY(o.id, N''IsSystemTable'') = 1'
select *
from @t
order by CONVERT( bigint,REPLACE (data, ' KB','')) DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment