Many a times we need to find details about SQL server installation when inheriting a new environment or a setup. One way to figure it out is by reading a registry.

If you have been working on windows since long time you should be aware of registry. Below is a snapshot of details about Microsoft SQL Server contained in Registry. Open RUN command window and type regedit to open up the registry.

1_t-sql script to find the cd key from registry

Open up registry and navigate to HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\MICROSOFT SQL SERVER\MSSQL12.SQL2014\Setup (for SQL Server 2014). On the left hand pane there are multiple setup configuration option listed. So, to get value of SQLPath option we need to write below T-SQL

The output of the above query is shown below.

2_t-sql script to find the cd key from registry

The procedure xp_regread is extended undocumented stored procedure to read registry values.  The first parameter is the root node, second is the path and the third one the key value to get the value of.  Replace the key value ‘SQLPath’ with productcode to get the CD key.

For SQL2005 version the values for 2nd and 3rd parameter are “SOFTWARE\Microsoft\Microsoft SQL Server\80\Registration” and “CD_KEY” respectively.


Like us on FaceBook Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook