-->

Ads 720 x 90

Script to Track SQL Database Growth

Here is the script that keep track of the database growth over a period of time; store the results on a separate 'dba' database for historical purposes.
 
 
 
;WITH c AS (
SELECT
rn = ROW_NUMBER() OVER( ORDER BY backup_start_date DESC )
,BackupDate = CONVERT(VARCHAR(10),backup_start_date, 111)
,SizeInMBs=FLOOR(backup_size/1024000)
FROM msdb.dbo.backupset
WHERE database_name = DB_NAME() -- put your databaseName here
AND type = 'd'
)
SELECT c.* ,diff =SizeInMBs -(SELECT SizeInMBs FROM c c2 WHERE rn = c.rn+1 )
FROM c
ORDER BY 1 ASC

Related Posts

Total Pageviews

Subscribe Our Newsletter