Saturday, July 23, 2011

How can I find the SQL Server CD key I used to install? It would be great to get this information from my desktop.


Answer:
As said the easy way is to get to the remote machines registry key settings and search for the same. The location to look for this CD keyis: 
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\80\registration\CD_KEY
More often than not this is not a feasible option. But donot deter, here is a cool undocumented command that can help you get this information from the registry. It is called the xp_regread . As the name suggests its used to read the registry values.
USE master
EXEC xp_regread 'HKEY_LOCAL_MACHINE',
                'SOFTWARE\Microsoft\Microsoft SQL Server\80\registration',
                 'CD_KEY'
I think the three parameters are self explanatory seeing the registry key we have to access. Since this extended stored procedure is un-documented. Use this with care. The systems adminsitrator can disable all these stored procedures at your work place ... :) ... And Microsoft can remove these stored procedures without warning.
Having seen the use of this extended procedure usage, lets get one more important registry key. I've also been asked how can we find theMDAC Version from the ISQLW window. And working on the same logic here is the solution.
EXEC master..xp_regread
    N'HKEY_LOCAL_MACHINE',
    N'Software\Microsoft\DataAccess',
    N'Version'

I think you should be able to decifer the appropriate registry key we are trying to access.

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Deep's | Bloggerized by Deep - Deep's Templates | ElearSQL-Server