Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Need Result in PIVOT Style

Author  Topic 

poratips
Posting Yak Master

105 Posts

Posted - 2014-12-01 : 19:53:32


Database_Name FULL - D DIFF - I LOG - L
DB1 D L
DB2 D
model D L
DB3 D I L
msdb D
DB4 D I L
DB5 D I L
ReportServer D I L
ReportServerTempDB D I L
DB5 D I L
DB6 D I L

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2014-12-01 : 23:49:11
[CODE]SELECT DatabaseName, [D] as [Full - D], [I] as [Diff - I], [L] as [Log - L]
FROM (SELECT distinct sdb.Name AS DatabaseName, bus.type
FROM sys.sysdatabases sdb
LEFT OUTER JOIN msdb.dbo.backupset bus ON bus.database_name = sdb.name
)P
PIVOT (MAX(type) FOR Type IN ([D],[I],[L]))pvt
[/CODE]

--
Chandu
Go to Top of Page
   

- Advertisement -