Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


An easy way to track the growth of your database


An easy way to track the growth of your database

Author
Message
rsloan
rsloan
SSC Journeyman
SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)SSC Journeyman (75 reputation)

Group: General Forum Members
Points: 75 Visits: 87
Can the same thing be accomplished in Microsoft Access?
Yogesh Ranade
Yogesh Ranade
SSC Veteran
SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)

Group: General Forum Members
Points: 221 Visits: 284
nice script...i just added it to my DBA dashboard :-D...i already had another but this is better
bpowers
bpowers
Old Hand
Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)Old Hand (317 reputation)

Group: General Forum Members
Points: 317 Visits: 960
How could we modify the code to include the growth of the log file?
Michael.Beeby
Michael.Beeby
SSC Veteran
SSC Veteran (236 reputation)SSC Veteran (236 reputation)SSC Veteran (236 reputation)SSC Veteran (236 reputation)SSC Veteran (236 reputation)SSC Veteran (236 reputation)SSC Veteran (236 reputation)SSC Veteran (236 reputation)

Group: General Forum Members
Points: 236 Visits: 673
In the interim you could:

select BackupDate = convert(varchar(10),backup_start_date, 111), SizeInGigs=
CAST(round(backup_size/1073741824,4) AS decimal(18,4)),
backup_size AS [Raw backup_size],
CASE TYPE
WHEN 'D' THEN 'Full'
WHEN 'F' THEN 'Filegroup'
WHEN 'I' THEN 'Differential'
WHEN 'L' THEN 'Log'
ELSE 'Unknown'
END AS Type
from msdb..backupset
where database_name = 'ROOMBOOKING' --and type = 'D'
order by backup_start_date DESC
Greg Drake
Greg Drake
Mr or Mrs. 500
Mr or Mrs. 500 (502 reputation)Mr or Mrs. 500 (502 reputation)Mr or Mrs. 500 (502 reputation)Mr or Mrs. 500 (502 reputation)Mr or Mrs. 500 (502 reputation)Mr or Mrs. 500 (502 reputation)Mr or Mrs. 500 (502 reputation)Mr or Mrs. 500 (502 reputation)

Group: General Forum Members
Points: 502 Visits: 534
That is a nice little query. Here's my quick re-write to show all databases and track percent growth since the first backup on record.


SELECT
   'database_name' = mdbus.database_name
   ,'backup_start' = mdbus.backup_start_date
   ,'duration' = CASE
      WHEN (datediff([second], mdbus.backup_start_date, mdbus.backup_finish_date) / 60 / 60) >= 100 THEN '100+ hours'
      ELSE isnull(
               right('0' + cast( (datediff([millisecond], mdbus.backup_start_date, mdbus.backup_finish_date) / 1000 / 60 / 60) AS varchar(10)), 2)
         + ':' + right('0' + cast(((datediff([millisecond], mdbus.backup_start_date, mdbus.backup_finish_date) / 1000 / 60) % 60) AS varchar(10)), 2)
         + ':' + right('0' + cast(((datediff([millisecond], mdbus.backup_start_date, mdbus.backup_finish_date) / 1000) % 60) AS varchar(10)), 2)
         + '.' + right('00' + cast( (datediff([millisecond], mdbus.backup_start_date, mdbus.backup_finish_date) % 1000) AS varchar(10)), 3)
      , '')
   END
   ,'size_gb' = convert(decimal(10,2), (convert(float, mdbus.backup_size) / 1024 / 1024 / 1024))
   ,'percent_growth' = convert(decimal(10,2), (((convert(float, mdbus.backup_size) - mdbus_first.backup_size) / mdbus_first.backup_size) * 100))
FROM
   msdb.dbo.backupset mdbus
   INNER JOIN
   (
      SELECT
         database_name
         ,'backup_set_id' = min(backup_set_id)
      FROM
         msdb.dbo.backupset
      GROUP BY
         database_name
   Wink mdbus_first_rec ON (mdbus.database_name = mdbus_first_rec.database_name)
   INNER JOIN
   (
      SELECT
         database_name
         ,backup_set_id
         ,backup_start_date
         ,backup_size
      FROM
         msdb.dbo.backupset
   Wink mdbus_first ON (mdbus.database_name = mdbus_first.database_name AND mdbus_first_rec.backup_set_id = mdbus_first.backup_set_id)
WHERE
   mdbus.[type] = 'd'
ORDER BY
   mdbus.database_name
   ,mdbus.backup_start_date DESC


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search