SQL Bank Log in Restoring Pending

0

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

    
asked by anonymous 03.07.2018 / 15:46

1 answer

0

The SQL Server has a log of these actions, in the case of restore, in the restorehistory table.

Here a query that will show the last restore 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

    
03.07.2018 / 15:53