SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Database State and Backup Information


Database State and Backup Information

Author
Message
Henrico Bekker
Henrico Bekker
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7494 Visits: 5012
Comments posted to this topic are about the item Database State and Backup Information

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle
Abrar Ahmad_
Abrar Ahmad_
SSC Eights!
SSC Eights! (892 reputation)SSC Eights! (892 reputation)SSC Eights! (892 reputation)SSC Eights! (892 reputation)SSC Eights! (892 reputation)SSC Eights! (892 reputation)SSC Eights! (892 reputation)SSC Eights! (892 reputation)

Group: General Forum Members
Points: 892 Visits: 1305
Good work!

but you seems to use extra(not required) parenthesis. might be good, but affected readability a bit. (just general comments not to take it serious).


2ndly, the code segment
Convert(real(256), MAX(u.backup_size), 101),'NA'))/1024)/1024


may result into truncation of data... !! not specific to this problem but i am trying to raise a general warning here that the code segment may have this in addition

Convert(real(256), MAX(u.backup_size), 101),'NA'))/1024.0000)/1024.0000


as you may know that Sql Server may return results in INT data type rather than in fractional (required format), and the CONVERT function will certainly would receive already truncated data (+ not rounded data) and consequently, u may get fractional truncation summation error in matter of summation of large number of records.

I hope so, u may get what i intended for.

Please don't forget to comment over it.

& Thanks
LondonNick
LondonNick
SSC-Addicted
SSC-Addicted (444 reputation)SSC-Addicted (444 reputation)SSC-Addicted (444 reputation)SSC-Addicted (444 reputation)SSC-Addicted (444 reputation)SSC-Addicted (444 reputation)SSC-Addicted (444 reputation)SSC-Addicted (444 reputation)

Group: General Forum Members
Points: 444 Visits: 516
You may want to consider differentiating between types of backups. You may have log backups running fine but no full backups taking place.
Also I would consider including databases which do not have records in msdb.dbo.backupset to highlight any database for which no backups have taken place.



Henrico Bekker
Henrico Bekker
SSCertifiable
SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)SSCertifiable (7.5K reputation)

Group: General Forum Members
Points: 7494 Visits: 5012
Noted, and thank you for the feedback.

SELECT   t.name as [DB Name],
t.user_access_desc as [Access State],
t.state_desc as [Online/Offline],
((SELECT (CASE t.is_in_standby WHEN 0 THEN 'No' WHEN 1 THEN 'Yes' ELSE 'Other' END))) as [In Standby],
(COALESCE(Convert(datetime, MAX(u.backup_finish_date), 101),'Not Yet Taken')) as [Last BackUp Taken],
ROUND((((COALESCE(Convert(real(256), MAX(u.backup_size), 101),'NA'))/1024.000)/1024.000),3) as [Backup Size in MB],
(COALESCE(Convert(varchar(10),MAX(datediff(d, getdate(), u.backup_finish_date))),101)) as [Days since Backup],
(COALESCE(Convert(varchar(12), MAX(u.type), 101),'NA')) as [Backup_type],
(COALESCE(Convert(varchar(12), MAX(u.user_name), 101),'NA')) as [User Name]


FROM SYS.DATABASES t
INNER JOIN msdb.dbo.BACKUPSET u
ON t.name = u.database_name
GROUP BY t.Name,t.is_in_standby, t.user_access_desc, t.state_desc
ORDER BY t.Name



-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle
Iwas Bornready
Iwas Bornready
SSC-Insane
SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)

Group: General Forum Members
Points: 22396 Visits: 885
Thanks for the script.
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