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?
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?
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