Here's a way to get the server and database name of the content database that a site belongs to using C#:
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administrator;
public class Test
{
private static SPGlobalAdmin oGlobAdmin = new SPGlobalAdmin();
public static SPVirtualServer GetVirtualServerBySite(SPSite oSite)
{
foreach(SPVirtualServer iServer in oGlobAdmin.VirtualServers)
{
foreach(SPSite iSite in iServer.Sites)
{
if(iSite.ID == oSite.ID)
{
return iServer;
}
}
}
throw new IndexOutOfRangeException("Unable to find site in configuration database: " + oSite.Url);
}
public static void Main(String[] Args)
{
SPSite oSite = new SPSite([Your site's URL here]);
SPVirtualServer oVS = GetVirtualServerBySite(oSite);
string SPContentDBServer = oVS.ContentDatabases[0].Server;
string SPContentDB = oVS.ContentDatabases[0].Name;
Console.WriteLine(SPContentDBServer);
Console.WriteLine(SPContentDB);
}
}
Hopefully someone finds this the least bit interesting...Personally I'm trying to recreate the connection string for the SharePoint DB, but shhhhh, don't tell anyone. Mucking w/ the SharePoint databases is not supported by MS.