How To Find The Physical Size Of SQL Server Tables And Indexes
Inspired by Shannon’s post (give me the size of data and indexes for a file in an oracle database please), I found a SQL statement that finds the size of each table and index in a SQL Server database. I also found that there are a ton of different ways to get this information. Below is the method that I is most beneficial to me:
EXEC sp_spaceused GO DECLARE @spaceUsed TABLE ( name varchar(255), rows int, reserved varchar(50), data varchar(50), index_size varchar(50), unused varchar(50)) INSERT INTO @spaceUsed EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'" SELECT name, rows, left(reserved,len(reserved)-3) as [reserved (KB)], left(data,len(data)-3) as [data (KB)], left(index_size,len(index_size)-3) as [index_size (KB)], left(unused,len(unused)-3) as [unused (KB)] FROM @spaceUsed order by rows desc
Author
Stewart Schatz
More Stories
Quick Tip: Hold All JDE Job Queues
The following SQL statement will put all JDE Job Queues on hold: UPDATE SY920.F986130 SET QCQUSTS='02' This statement is very...
How To Disable Client Package Deployment
If you have a development client that has been neglected and JDE wants you to install 15 update packages but...
Quick Tip: Limit The Number Of Rows Returned From A SQL Query
This is pretty basic, but I had to look up the syntax to use for SQL on IBM DB2 so...
Quick Tip: Where Is An Application On The Menu?
The following SQL will give you a good idea if an application or UBE is on the menu and where...
Quick Tip: Decline All Update Packages Using SQL
A quick way to decline all packages that have been marked for deployment on a development client is use SQL:...
Quick Tip: Change A Scheduled Job’s Time Zone Using SQL
If you work with multiple time zones, especially if one uses Daylight Saving Time and the other does not, it...
Average Rating