Ever wake up one day to discover your Onepoint, SystemCenterReporting or other SQL database has grown unexpectedly?
Have you ever been asked to estimate future growth of SQL databases in your environment?
If the answer to either of the above, then check this out. A colleague sent me a script the other day makes the task of monitoring and reporting the growth trends of SQL databases an easy task. The following SQL script creates a stored procedure for generating usage data, and a table in the master database for storing this data (script is also well-commented if you’re interested in reading how it collects this data). In the 1st installment, we'll actually configure the components for collecting usage data. Then in the 2nd installment, we'll take advantage of our MOM Reporting Server by creating some simple trend reports in SQL Reporting Services to graphically display the data we’ve collected.
Run the script
Start by running the following script in SQL Query Analyzer on the MOM Database Server or other target SQL Server.
http://www.it-jedi.net/scripts/dbsizewatch.htm
Validate components and functionality
Once you’ve verified both the stored procedure and the table are present, run the stored procedure to populate the table.
The table reports 1) database and transaction log space size, 2) space used and 3) space available.
Figure 1 – Table output

Create SQL job to execute on a schedule
Now it’s time to schedule the daily run of the stored procedure to log the data. (I actually modified this script a bit to include a timestamp so the script could be run multiple times daily if necessary).
Table 1 - Job Properties:
|
Tab |
Setting |
|
General |
Enter a job name, owner (should be a local administrator), and a description. Default target of local server will suffice. |
|
Steps |
General tab:Click
the New button. Enter step name ‘Gather DB Stats’. In the command field,
enter execute usp_DBSizeWatch Advanced tab: accept default values. |
|
Schedule |
Click the New Schedule button. Enter schedule name ‘Daily Run’. Select Recurring radio button, then click Change, and set desired schedule time and frequency. |
|
Notification |
Select checkbox labeled ‘Write to Windows application event log’. This will generate an event on job failure that will be trigger alerts from MOM SQL Mgmt Pack rules. |
Figure 2 – SQL Job Properties
