|
|
| |

How do I read from the registry via Transact-SQL?
Answer:
You can use the xp_regread undocumented extended stored procedure
to read from the registry via Transact-SQL.
This is the syntax of the xp_regread:
EXECUTE xp_regread [@rootkey=]'rootkey',
[@key=]'key'
[, [@value_name=]'value_name']
[, [@value=]@value OUTPUT]
|
For example, to read into the variable @test from the value 'TestValue'
from the key 'SOFTWARE\Test' from the 'HKEY_LOCAL_MACHINE', run:
DECLARE @test varchar(20)
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Test',
@value_name='TestValue',
@value=@test OUTPUT
SELECT @test
|
See this article to get more useful undocumented extended stored procedures:
Useful undocumented extended stored procedures
|
|
|