Link to home
Start Free TrialLog in
Avatar of sg05121983
sg05121983

asked on

SQL servers backup report

Hi All,

Our Requirement is we need to send SQL Server backup status report to client on weekly basis which should include daily incremental (Mon-Fri) and Full backup (Sat) backup report in the form of csv\excel.

can some one share the tsql script for our requirement or please guide me how to modify below script as per our requirement.

Select @@servername, M.Name, M.crdate, Current_DBSize = Str(Convert(Dec(15),Sum(Size))* 8192/ 1048576,10,2)+ ' MB',
K.Backup_Start_Date, K.Backup_Finish_Date,
CompletionTime =  Cast((Datediff(MI, K.Backup_Start_Date, K.Backup_Finish_Date)/60) As Char(2)) + ' Hr : ' +
Cast((Datediff(MI, K.Backup_Start_Date, K.Backup_Finish_Date) % 60) As Char(2)) + ' Min : ' +
Cast((Datediff(ss, K.Backup_Start_Date, K.Backup_Finish_Date) % 60) As Char(2)) + ' Sec' ,
Backup_Type = Case Upper(K.Type)
      When 'D' Then 'Full Backup'
      When 'I' Then 'Differential'
      When 'L' Then 'Log'
      When 'F' Then 'File Or Filegroup'
      When 'G' Then 'Differential File'
      When 'P' Then 'Partial'
      When 'Q' Then 'Differential Partial'
      End,
K.User_Name
From Sys.SysDatabases M (Nolock)
Inner Join Sys.SysAltFiles SF (Nolock)
      On M.DBId = SF.DBId
Left Outer Join MSDB..BackupSET K (Nolock)
      On M.Name = K.Database_Name And K.Type = 'D'
      And K.Backup_Start_Date >= '2010-01-22 00:00:00:000' --- And K.Backup_Start_Date < '2008-07-15 20:00:00:000'
Where M.Dbid <> 2
Group By M.Name, M.crdate, K.Backup_Start_Date, K.Backup_Finish_Date, K.Type, K.User_Name
Order By M.Name -- K.Backup_Start_Date
ASKER CERTIFIED SOLUTION
Avatar of jogos
jogos
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sg05121983
sg05121983

ASKER

Thnaks a lot Jogos for your help :)

I will test above query as per your suggestions and will let you know the results.
--