#
Retrieving SQL and OLAP Database Sizes
The stored procedure GetTableDataSizeByYear
retrieves the data size and reserved space of SQL and OLAP databases for a specific year. This guide provides instructions on how to use this stored procedure to obtain information about database sizes, which is essential for capacity management and future disk space projections.
To create and run the stored procedure in SQL Server Management Studio (SSMS), follow these instructions:
On your machine, open SQL Server Management Studio (SSMS), click on Connect, then select the Database Engine. Enter the server name and choose an Authentication type.
Connect to Database Engine
Connect to Server
In the left pane, go to Databases > <database_name> > Programmability > Stored Procedures.
Stored Procedure
Right-click on
dbo.GetTableDataSizeByYear
and select Execute Store Procedure...Execute Stored Procedure
Type your desired year under the Value column.
Click OK.
Execute Procedure
The result should include columns for the year, table name, row count, data size, and reserved size for the SQL Database. For the OLAP Database, the results should display the approx_olap_db_size_gb.
SQL Database Size Query Results
The --All-- entry under the TableName column represents the aggregated values for all tables.
OLAP Database Size Query Results
The output is an estimate of the size, and the numbers may differ from the actual MDF (SQL Server data file) size due to the inclusion of other data not reflected in this result set.
You can use the results above to create a bar chart for capacity management and future disk space projections, utilizing the data from the query results.
SQL Database Size Graph