Cross-database views and mirroring in SQL Server
-
06-07-2019 - |
Question
I have a question about mirroring and cross-db views. We have a view in database X which references database Y on the same server S1. The databases X & Y are both mirrored onto another server S2. The problem is: if db X fails over to S2, the view which references db Y is now looking on S2, but db Y may not have failed over. What is the best way around this? Can you create a mirrored couple, so that if 1 on the dbs in the couple fails over, the other one does too?
Thanks
Solution
We detect that the database has failed and manually failover the second database. This article will likely help; basically it is a hack on the failover of the first database in the witness that lets you trigger a failover of the second database.
OTHER TIPS
If you upgrade to SQL 2012 you can use the Always on Availability Groups function to group databases for this very purpose.