Monthly Archives: November 2010

You are browsing the site archives by month.

How to: Find SharePoint’s Database server and instance

Here’s an easy way to get the server and instance name of the database server your SharePoint server is using. It’s very useful for constructing connection strings on the fly (hint, hint).


public string FindSPSQLServerName()
{
     String sServerName = "";
     SPWebService service = SPFarm.Local.Services.GetValue();

     SPDatabaseServiceInstance s = service.DefaultDatabaseInstance;
     sServerName = s.Server.DisplayName + "\" + s.Instance;
     return sServerName;
}

Switch to our mobile site