Wednesday, March 7, 2012

how to find media name of the last successful backup via SMO

Would you show me how to use SMO to find the name of the media of the last
succesful backup via SMO?
I use maintenance plan to do backup. I need to find the name of the media
(backup file) that was created for the last backup.
thanks,
ktm
I did not get a response to my question. I am not sure if my question was
not clear enough, or SMO has no support for what I need. Anyway below is the
query in SQL 2005 that i think can provide the correct device name of the
last backup of a database. I need an easier way via SMO to find the device
name.
select top 1 database_name, backup_set_id, type, physical_device_name
'DeviceName'
,backup_start_date Start, backup_finish_date Finish
,is_damaged 'Damaged', has_incomplete_metadata 'Incomplete'
FROM msdb..backupmediafamily f, msdb..backupset s
where upper(database_name) = 'ADVENTUREWORKS'
and f.media_set_id = s.media_set_id
order by backup_finish_date desc
thanks,
ktm
"ktmd" wrote:

> Would you show me how to use SMO to find the name of the media of the last
> succesful backup via SMO?
> I use maintenance plan to do backup. I need to find the name of the media
> (backup file) that was created for the last backup.
> thanks,
> ktm
>

No comments:

Post a Comment