I am writing a custom web-part in SP 2013 environment. We have 3 SQL 2012 servers in Always On Availability group. Where one is Primary and other two are secondary. They are configured for failover scenarios.

While preparing connection-string for my code to connect to the database, i am not sure about what to provide for the Data Source portion of the connection-string. Please help me out to decide which among the following is the best to use, to avoid any issues in future.

  1. Server Name of the primary server.
  2. SQL Server group name.
  3. Availability group listener name.

I already understand that the first option Server Name, is not a good option in this configuration. As, it may change in a failover scenario.

1 Answer 1


For Always On availability groups:

Go for option 2. As this MSDN article explains, you need to point to the Availability group listener name. Refer to the section "Install and Configure SharePoint 2013".

For Clusters:

I would say option 3, but take into account this:

If it's an specific instance within the cluster:

DATA SOURCE=ClusterName\SQLInstanceName;

If it's the cluster's default instance:

DATA SOURCE=ClusterName;

-Hope it helps

  • I am also having same understanding. But, do you have any references(may be from Microsoft), which supports what we think. If you can get that it will add weight to the answer.
    – Amit Tyagi
    Mar 4, 2015 at 19:35
  • I just edited my answer. The original answer was true for clusters, but not for AlwaysOn AG. Mar 6, 2015 at 14:35

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.