How to: Find SharePoint’s Database server and instance
Posted November 12th, 2010 by Eric WebbHere’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<SPWebService>(); SPDatabaseServiceInstance s = service.DefaultDatabaseInstance; sServerName = s.Server.DisplayName + “\\” + s.Instance; [...]
Filed under:general