We usually want to know whether the database has grown and how much it has grown. You may think of comparing the sizes of databases in various historical periods.
But how can we get these historical data? It seems that there is no good way
I am talking about how to view the database growth by viewing the backup records.
First, we should back up the database frequently, which can be implemented by Job.
The database backup records are stored in the backupset table of the msdb database. by viewing the backup records, we can get a rough estimate of the database growth.
The script is as follows:
Copy codeThe Code is as follows:
Select
BackupDate = convert (varchar (10), backup_start_date, 111)
, Sizeingig = floor (backup_size/1024000000) -- convert the size to GB.
From msdb... backupset
Where
Database_name = 'databasename '-- Name of the database you want to view. Replace
And type = 'D'
Order
Backup_start_date desc
The output result is as follows:
BackupDate sizeingig
2009/06/22 2
2009/06/04 1