Friday, October 12, 2012

Script for Backuptype and Backup location for each database..

Hello,

One of my frd asked me to below mentioned requirement.Actually I don't have experience on scripting level.but just I tried with equal join with temporary table.and get output as requirement.
=======AweSome====
So I would like to share these scripts to each one of you...
This is  for finding the "databasename" , "backup location" , "backup type","Backup finished Date" and "Backup size"
1)========================
create table #temp(DBname varchar (30), Path nvarchar(100), type varchar (30),backupfinishdate date)
insert into #temp
select database_name,physical_device_name,type as backuptype,backup_finish_date  from backupset bs,backupmediafamily bm where bs.media_set_id=bm.media_set_id
go
update #temp set type = 'FULL' where type='D'
go
update #temp set type = 'Diff' where type='I'
go
update #temp set type = 'Log' where type='L'
go
select * from #temp
drop table #temp

=========================
select database_name,physical_device_name,
case bs.type
when 'D' then 'Full'
when 'I' then 'Differencial'
When 'L' Then 'Tlog'
end as Backtype,backup_finish_date,
CAST((bs.backup_size/1024/1024) AS int) AS [Size in MB],
 from backupset bs,backupmediafamily bm where bs.media_set_id=bm.media_set_id

Please find below attached is output for above script..





Thanks
ASR

No comments:

Post a Comment