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.
0 0 votes
Article Rating
Subscribe
Notify of
guest

Solve the maths problem shown below before posting: *

0 Comments
Inline Feedbacks
View all comments