Can I find an installed SQL Server's CD key from the Windows registry? I have the software, but I've misplaced the key.
Specific paths to registry keys vary based on how you've installed and upgraded SQL Server. In my registry, the CD key is at the following registry path:
\Microsoft\Microsoft SQL Server
On your machine, the CD key should be in the same registry key or one similar to it.
Alternatively, you could use the undocumented xp_regread extended stored procedure and read the value directly, as this example syntax shows:
EXEC xp_regread 'HKEY_LOCAL_MACHINE',
The first parameter specifies the root key in the registry. The second parameter is the path to the key. The third parameter specifies the key value that you're looking for. Note that you should be wary of using xp_regread in an application because it's an undocumented function that Microsoft can remove without warning. However, using the extended stored procedure for ad hoc access is perfectly safe.