RegQueryValueEx() returned error 2, 'The system cannot find the file specified.'

Hi Guys,

I am using master..xp_regread and its giving me error like
RegQueryValueEx() returned error 2, 'The system cannot find the file specified.'

It is working fine with some instances of SQl Server 2008 R2 and on some its giving above error.

does anyone worked on this ? it seems Sql Issue.

Please write me back if you have any idea or solution for above issue.

Post the query you are using. Also see if this article helps you. If you are using xp_regread, its an undocumented function, so the expert advice is to avoid using them if you can. See here

By the way, I am no expert on RegQueryValueEx or on xp_regread. All my expertise comes from couple of minutes of binging the web. :smile:

Thank #jamesk,

Please below query which i am using
Yes , its undocumented , but is there any other way to read registry key value using sql server ?
DECLARE @value VARCHAR(100)

DECLARE @key VARCHAR(100)

SET @key = 'software\axxia\server'

EXEC master..xp_regread
@rootkey = 'HKEY_CURRENT_USER',
@key = @key,
@value_name = 'bin',
@value = @value OUTPUT

print @value

From what I can see your syntax appears fine. Does the entry in the registry exist for the values you are providing in the query?

Yes,

It exist