We have a SharePoint oriented environment where all the content and config databases are hosted on SQL Server. My question is there some way from SQL Server end to find out if the content databases are attached to SharePoint CA? The only way I know to find this info is to log into the server and run the Get-SPDatabase command to get all the databases attached to the CA. Can this somehow be achieved from backend? By using SQL Queries.


2 Answers 2


There is a rough way to see which database is in use running the query sp_who which outputs (among other things) loginame, hostname and dbname. You will find the connections to all databases in this sql server instance.

If you save the query to a file, you can easily import it to excel to filter its content.

  • Is this the only way to get this? Also the results using this will be same as the one with we get using Get-SPDatabase?? May 15, 2015 at 11:41
  • @user2068804 From SQL Server you could use the profiler tool as well, but it needs heavy filtering. And it's not the same as Get-SPDatabase which will output all the databases in one time. sp_who outputs connections, and you usually have more than one connection to each database.
    – Benny Skogberg
    May 15, 2015 at 11:44

You shouldn't be querying SharePoint databases directly, no matter what data you want to get.

More info: Here and here

  • I'm aware of this, but the query I'm asking for wil just be a select query. I don't think that will have any harm. Please correct me if i'm wrong. May 15, 2015 at 11:27
  • @user2068804 even select queries is unsupported actually May 15, 2015 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.