Sql-server – Capture when any database is restored on the server

restoresql serversql server 2014

Is there any way that I can identify when a database is restored on the server? I created a server trigger but only triggers when I create a new database not after is restored from another one.

I'm using SQL Server 2014, trying to achieve this using MSMS, using msdb.dbo.restorehistory is good but I don't want to create a job for that, trying to find something straightforward

I want to know as s DBA when any database is created or restored, just for control.

I found that there is no DDL trigger for RESTORE, there is however Event Notification for the AUDIT_BACKUP_RESTORE_EVENT but I didn't find any good example of how to use it.

could someone tell me which accounts I need to merge? I'm confuse, I did it with my account on stackoverflow and it says is already linked and I can't continue

Best Answer

Under the assumption that you are using SQL Server, you can create a trigger against the msdb..restorehistory table.

Go ahead and query that table to see what information is in there; I think you can achieve what you are doing.

See Know when a database has been restored