December 1, 2014 at 5:51 pm
Hi,
I need to list the current DB Backup Set up list in PIVOT STYLE.
I need following way:
Database_NameFULL - DDIFF - ILOG - L
DB1DL
DB2D
modelDL
DB3DIL
msdbD
December 1, 2014 at 9:08 pm
I got it, Thanks.
;WIth mycte as (SELECT
s.database_name,
s.[type]
,row_number() Over(Partition by s.[type] Order by s.backup_finish_date DESC ) RN
FROM msdb.dbo.backupset s
INNER JOIN msdb.dbo.backupmediafamily m ON s.media_set_id = m.media_set_id)
Select database_name, max(case when [type]='D' Then 'D' Else '' End) 'FULL--D'
, max(case when [type]='I' Then 'I' Else '' End) 'DIFF - I'
, max(case when [type]='L' Then 'L' Else '' End) 'LOG - L'
from mycte
--Where rn=1
Group by database_name
December 1, 2014 at 10:46 pm
poratips (12/1/2014)
I got it, Thanks.;WIth mycte as (SELECT
s.database_name,
s.[type]
,row_number() Over(Partition by s.[type] Order by s.backup_finish_date DESC ) RN
FROM msdb.dbo.backupset s
INNER JOIN msdb.dbo.backupmediafamily m ON s.media_set_id = m.media_set_id)
Select database_name, max(case when [type]='D' Then 'D' Else '' End) 'FULL--D'
, max(case when [type]='I' Then 'I' Else '' End) 'DIFF - I'
, max(case when [type]='L' Then 'L' Else '' End) 'LOG - L'
from mycte
--Where rn=1
Group by database_name
I'm not sure that you do have it. Let's say that your FULL backup ran yesterday, that your first DIF ran today, and the last LOG file backup ran a week ago but are supposed to run once per hour, what do you think that the query above will show? I'm thinking that it's going to look like everything is fine when it's not.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply