SQL Database Log in Restoring Pending

Asked

Viewed 36 times

0

I have an SQL database that was accessed by someone else and it entered "Restoring Pending" as soon as they accessed. Is there any way to extract some log or any other more detailed way to know how, who and when it was done?

1 answer

0

The SQL Server has a log of these actions, in the case of Store, on Tablea restorehistory.

Here a query that will show the last Store for each database, should help you:

WITH LastRestores AS
(
SELECT
    DatabaseName = [d].[name] ,
    [d].[create_date] ,
    [d].[compatibility_level] ,
    [d].[collation_name] ,
    r.*,
    RowNum = ROW_NUMBER() OVER (PARTITION BY d.Name ORDER BY r.[restore_date] DESC)
FROM master.sys.databases d
LEFT OUTER JOIN msdb.dbo.[restorehistory] r ON r.[destination_database_name] = d.Name
)
SELECT *
FROM [LastRestores]
WHERE [RowNum] = 1

Credits: how-to-query-last-Restore-date-in-sql-server

Browser other questions tagged

You are not signed in. Login or sign up in order to post.