Sql to get most recent full backup file for a specific database in sql server

后端 未结 4 1105
长发绾君心
长发绾君心 2021-02-19 08:03

I need an sql command (dbcc or extended stored procedure?) or something that can be called from a sql server stored procedure to get the most recent full backup file available f

4条回答
  •  青春惊慌失措
    2021-02-19 08:40

    Just query msdb..backupset (MSDN) on the "source" prod server

    And a working example (SQL Rockstar) too

    Edit, 2018

    SELECT
        bs.database_name,
        bs.backup_start_date,
        bmf.physical_device_name
    FROM
        msdb.dbo.backupmediafamily bmf
        JOIN
        msdb.dbo.backupset bs ON bs.media_set_id = bmf.media_set_id
    WHERE
        bs.database_name = 'MyDB'
    ORDER BY
        bmf.media_set_id DESC;
    

提交回复
热议问题