Click here to monitor SSC
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)

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: 5542 | Views in the last 30 days: 3
 
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