Determine Sharepoint version using SQL query on the Sharepoint config database

We recently had a client who lost their Sharepoint application (web front-end) server, fortunately their Sharepoint databases were located on a different SQL server (which was being backed up). So we started to rebuild the Sharepoint application server & proceeded to restore the content (websites).

When we ran through the Sharepoint configuration wizard which connects the application server to the Sharepoint config database it failed at step 2 with the following error:
“failed to connect to the configuration database an exception of type system.security.securityexception was thrown.
Additional exception information: access denied”

This seemed strange since we were definitely using the correct Sharepoint database user, to be sure we verified the permissions were correct in SQL. It turned out the problem is caused by the Sharepoint config database version running a slightly different version to the application server (they need to be exactly the same).

How did we determine the Sharepoint version of the configuation database then?

Simple…..

The first way is to open a web browser and got to the site settings page (Site Actions > Site Settings > Modify All Settings).

The second method is to run a query against the databases.  Open SQL Server Management Studio, Connect to the server, new query, run the following:

SELECT [VersionId]
      ,[Version]
      ,[Id]
      ,[UserName]
      ,[TimeStamp]
      ,[FinalizeTimeStamp]
      ,[Mode]
      ,[ModeStack]
      ,[Updates]
      ,[Notes]
  FROM [SharePoint_Config].[dbo].[Versions] 
  WHERE VersionId = ‘00000000-0000-0000-0000-000000000000’ 
  ORDER BY Id DESC

 This returns:

VersionId Version Id UserName Updates
00000000-0000-0000-0000-000000000000 12.0.0.6219 4 MOSS\user 3
00000000-0000-0000-0000-000000000000 12.0.0.4518 1 MOSS\user 2

The top row is the latest version, if you have changed the database name from “SharePoint_Config” be sure to update the query to reflect the correct name. Check out this site to see what version you are running.

Once we determined the correct version we created the slipstreamed Sharepoint installation required, re-ran setup and bang everything worked correctly!

Jason Vigus

2 thoughts on “Determine Sharepoint version using SQL query on the Sharepoint config database


  1. The top row is the latest version, if you have changed the database name from “SharePoint_Config” be sure to update the query to reflect the correct name. Check out this site to see what version you are running.”?

  2. Hi, I am having the same problem. Sp farm has2verions, but db_config has only 1(missing the securitytoken service version) . How did you do to make the farm and db_config are the same. Thx in advance.

Comments are closed.