Question : How do I use SMO to get the latest backup path for a database?

Hi, I want to retrieve from a lot of SQL Servers, the path of their latest backup. Is it possible to get this information using SMO?

I can find the default backup path from the server, but that is not what I want.

Thanks for any help

Answer : How do I use SMO to get the latest backup path for a database?

you may use simple query against msdb to get the information

select
database_name,
case type when 'L' then 'Log' else 'Data' end as Backuptype,
physical_device_name,
backup_start_date
from msdb.dbo.backupset a
join msdb..backupmediaset b on a.media_set_id = b.media_set_id
join msdb.dbo.backupmediafamily c on a.media_set_id = c.media_set_id
where type in ('L','D') -- L = Logbackup, D = Databackup
order by backup_start_date desc, database_name asc, Backuptype
Random Solutions  
 
programming4us programming4us