Search code examples
sql-serverlinq-to-sqlconnection-stringmirroringhigh-availability

How can my web application find the currently running master database?


I'd like to set up two SQL Server 2008 R2 instances with synchronous mirroring and automatic failover. If I understand this scenario correctly, the SQL servers switch roles (principal and failover) whenever a failover occurs (please let me know if I'm wrong here).

What is the standard approach to locate the current primary database from the web application? I know I can specify the two server like this in the connection string:

Data Source=myPrincipalServerAddress;Failover Partner=myFailoverServerAddress;Initial Catalog=myDataBase;Integrated Security=True;

But does that also work properly if the servers are actually currently working the other way round? In other words, would this work just as well:

Data Source=myFailoverServerAddress;Failover Partner=myPrincipalServerAddress;Initial Catalog=myDataBase;Integrated Security=True;

I've found an msdn article on this subject, but it's not very explicit in this regard.

Thanks,

Adrian


Solution

  • without a witness there's no automatic failover. mirroring itself is transparent to your application because it's handled internally by the ADO.net provider.