Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer

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

SELECT * FROM DATABASE_MIRRORING_STATE_CHANGE

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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