Currently have this to get a value from the registry in TSQL. However, I need to get the DigitalProductId and it does not return the value required. I think its stored as a binary in the registry.
Any ideas?
DECLARE @retvalue int, @data varchar(500)
EXECUTE @retvalue = master.dbo.xp_instance_regread 'HKEY_LOCAL_MACHINE',
'SOFTWARE\Microsoft\Windows NT\CurrentVersion',
'DigitalProductId', @param = @data OUTPUT
PRINT 'ProductId: '+ @data
Edit: I have updated the question and the code.
DigitalProductIdis aREG_BINARYkey.xp_instance_regreadcasts everything it reads into a null-terminated string, so this won’t ever return anything meaningful if the string containsNULLs.xp_instance_regreadis an undocumented procedure that is not intended to be used in production environment. If you need to read the registry keys fromSQL Server‘s side, you better write your ownXPto do it.