SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Quick table size information

By Gabe Tower,

There are many reasons you might want to see the sizes of all tables on a database. Maybe you're part of an effort to try to trim down some of the more egrigious tables out there. Maybe you're doing index optimization and want to see how much space indexes are taking up in general. Maybe you're testing cleanup processes across a bunch of tables, and you want to quickly see the effect the cleanup has had.

There are many ways to get at table size information, but usually the easiest is sp_spaceused. The only drawbacks are it can only do one table at a time, and several of the values it returns are strings instead of numbers. This tends to be my go-to script for these sorts of queries because it's quick to run, lets me query the data afterwards, and when bound to some sort of shortcut, I can pull the information up at any time.

Just replace the database name using CTRL+SHIFT+M and let 'er rip!

Total article views: 741 | Views in the last 30 days: 1
 
Related Articles
ARTICLE

If you're confident about a change in your DB, triple check

Even planning allows for failure, sometimes you can't see everything else where you're standing.

ARTICLE

You're Gonna Dunk One Day

A look at some of the more interesting stories from a database perspective.

BLOG

Admitting When You're Wrong

As a father of two head-strong boys (inherited trait), I struggle with getting them to admit they ar...

ARTICLE

So You're the New DBA

In a new DBA role, Daryl Quadros brings us a list of the first tasks you should perform.

BLOG

10 signs you're not talking to a developer

Reblogged from the pluralsight blog: There are many types of developers out there. And while not all...

Tags
administration    
sp_spaceused    
table size    
 
Contribute