Last database restore

Configurare noua (How To)

Situatie

Mai jos este o procedura ce returneaza pentru bazele de date de pe serverul de sql pe care e rulata, ultima data cand a avut loc un restore pe acea baza.

Solutie

create procedure LastRestore

as

SELECT
destination_database_name
,bmf.physical_device_name
,restore_date
FROM
msdb.dbo.restorehistory
INNER JOIN msdb.dbo.backupset as bs ON bs.backup_set_id= msdb.dbo.restorehistory.backup_set_id
INNER JOIN msdb.dbo.backupmediafamily as bmf ON bs.media_set_id= bmf.media_set_id
WHERE restore_history_id IN
(
SELECT MAX(restore_history_id)
FROM msdb.dbo.restorehistory
WHERE restore_type = ‘D’
AND destination_database_name IN
(
SELECT DISTINCT destination_database_name
FROM msdb.dbo.restorehistory
)
GROUP BY destination_database_name
)
ORDER BY restore_date DESC

Tip solutie

Permanent
Etichetare:

Voteaza

(16 din 25 persoane apreciaza acest articol)

Despre Autor