Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Database State and Backup Information Expand / Collapse
Author
Message
Posted Thursday, April 22, 2010 1:21 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, August 28, 2014 2:39 AM
Points: 1,880, Visits: 2,846
Comments posted to this topic are about the item Database State and Backup Information

----------------------------------------------
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.
Post #908355
Posted Thursday, April 22, 2010 8:23 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, September 18, 2014 11:12 AM
Points: 212, Visits: 1,116
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
Post #908647
Posted Thursday, April 22, 2010 9:01 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, March 17, 2014 5:44 AM
Points: 391, 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.



Post #908702
Posted Thursday, April 22, 2010 9:35 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, August 28, 2014 2:39 AM
Points: 1,880, Visits: 2,846
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



----------------------------------------------
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.
Post #908753
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse