Get Default Database Infomation

SharePoint Short #15

Looking for a quick an easy way of retrieving the default content database information, like the SQL instance (i.e. servername\instance)?

string sqlServerInstance = SPWebService.ContentService.DefaultDatabaseInstance.NormalizedDataSource;

or individually

string sqlInstance = SPWebService.ContentService.DefaultDatabaseInstance.Instance;
string sqlServer = SPWebService.ContentService.DefaultDatabaseInstance.Server;

The SPWebService class provides an easy and quick way of retrieving this, along with the administration database specific properties.

This entry was posted in SharePoint Shorts and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve the maths problem shown below before posting: *