Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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)

Show database size info across an instance

By Richard Douglas,

This script will insert data about the sizes of all databases on the instance into a predetermined table - DatabaseGrowth. It can be used to perform a snapshot at a point in time by running in SSMS or made into a job to chart the growth of databases over time.

Please note that OBJECT_SCHEMA_NAME and DATA_COMPRESSION are SQL 2008 features.
If running on SQL Server 2005:
The condition using OBJECT_SCHEMA_NAME can be removed and replaced with an appropriate JOIN to sys.schemas.
Comment out the use of DATA_COMPRESSION WHEN creating storage table.

The code assumes the existance of the database DBAControl. This can be changed to use TempDB to test the code by replacing each occurence of the word "DBAControl".
Remember never run untrusted code on a Production Server, always review and then run on a development instance first!

Total article views: 5353 | Views in the last 30 days: 12
 
Related Articles
FORUM

Database

Database

FORUM

Database Sync

Database

FORUM

Database suspect

Database

FORUM
FORUM

Database Synchronization

Database Synchronization

Tags
database size    
t-sql    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones