I want to perform some sql when my database mirroring state changes

2 Answers 2


Create an event notification for the Database Mirroring State Change. See Implementing Event Notifications for how to design a service that processes the notification and does whatever is appropriate. Keep in mind that event notifications are asynchronous.


You can do this using SQL Server alerts, which can trigger a job after the WMI event occurs.

Your WMI Query in this case will be


More details (and scripts): http://msdn.microsoft.com/en-us/library/cc966392.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.