xp_regread - RegQueryValueEx() returned error 2, 'The system cannot find the file specified.'
xp_regread extended stored procedure can be used to read registry key values from the registry archive within MS SQL Server.
This t-sql undocumented extended stored procedure is not directly supported by Microsoft. So it is not recommended to use xp_regread on production systems.
It is very common if you are working with xp_regread to get the following sql exception.
The below t-sql error points that the registry entry does not exist, or the parameters you have supplied to the xp_regread statement has some improper values.
Let's first start with a proper xp_regread call.
Sample T-SQL Code using xp_regread Extended Stored Procedure
And the output registry key value is : "C:\Program Files\Adobe\Acrobat 8.0\"
Improper @value_name parameters passed to the xp_regread procedure
But if you execute the below script to get the registry value of the same registry entry like shown above Registry Editor screenshot, you will get some error from the sql engine.
The sql exception or the t-sql error displayed on the SQL Editor or SQL Server Management Studio will be as follows :
You can find information on how you can use the undocumented t-sql stored procedure on MS SQL Server version from SQL Server 2000 to SQL2005 and SQL2008 at SQL xp_regread Extended Stored Procedure.