xp_regdeletekeyThis extended stored procedure will delete an entire key from the registry. You should use it very carefully.这个过程可以从注册表删除一个键,使用时要谨慎。Syntax:
语法:EXECUTE xp_regdeletekey [@rootkey=]'rootkey',
                        [@key=]'key'  
For example, to delete the key 'SOFTWARE\Test' from 'HKEY_LOCAL_MACHINE', run:例如,从注册表里删除HKEY_LOCAL_MACHINE\OFTWARE\Test,运行:EXEC master..xp_regdeletekey
     @rootkey='HKEY_LOCAL_MACHINE',  
     @key='SOFTWARE\Test' xp_regdeletevalue
This extended stored procedure will delete a particular value for a key in the registry. You should use it very carefully.这个扩展过程可以删除注册表特定的键里特定的值,使用时要谨慎。Syntax:EXECUTE xp_regdeletevalue [@rootkey=]'rootkey',
                          [@key=]'key',
                          [@value_name=]'value_name' 
For example, to delete the value 'TestValue' for the key 'HKEY_LOCAL_MACHINE' from 'HKEY_LOCAL_MACHINE', run:例如,要删除键值HKEY_LOCAL_MACHINE\HKEY_LOCAL_MACHINE\TestValue,运行:EXEC master..xp_regdeletevalue
     @rootkey='HKEY_LOCAL_MACHINE',
     @key='SOFTWARE\Test',
     @value_name='TestValue' 
xp_regread
This extended stored procedure is used to read from the registry.这个扩展过程可以度曲注册表特定的键里特定的值。Syntax:语法:EXECUTE xp_regread @rootkey='HKEY_LOCAL_MACHINE',
                   @key='SOFTWARE\Microsoft\MSSQLServer\MSSQLServer'
                   ,@value_name='DefaultData']
                   , @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:
例如,要读取键值HKEY_LOCAL_MACHINE\HKEY_LOCAL_MACHINE\TestValue,运行:DECLARE @test varchar(20)
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
  @key='SOFTWARE\Test',
  @value_name='TestValue',
  @value=@test OUTPUT
SELECT @test 
xp_regwrite
This extended stored procedure is used to write to the registry.
这个扩展过程可以在注册表特定的键里写入特定的值。Syntax:语法:EXECUTE xp_regwrite [@rootkey=]'rootkey',
                    [@key=]'key',
                    [@value_name=]'value_name',
                    [@type=]'type',
                    [@value=]'value' 
For example, to write the variable 'Test' to the 'TestValue' value, key 'SOFTWARE\Test', 'HKEY_LOCAL_MACHINE', run:
例如,要在键HKEY_LOCAL_MACHINE\HKEY_LOCAL_MACHINE\TestValue写入Test,运行:EXEC master..xp_regwrite
     @rootkey='HKEY_LOCAL_MACHINE',
     @key='SOFTWARE\Test',
     @value_name='TestValue',
     @type='REG_SZ',
     @value='Test' 

解决方案 »

  1.   

    eg:declare  @path  varchar(200)  
    exec  master.dbo.xp_regread    
               'HKEY_LOCAL_MACHINE',  
               'SOFTWARE\Microsoft\MSSQLSERVER\setup',  
               'SQLPath',@path  output  
    set  @path  =  @path  +  '\data\'  
    print  @path/********修改服务器的认证方式 **********/
    exec master..xp_instance_regread N'HKEY_LOCAL_MACHINE',N'Software\Microsoft\MSSQLServer\SETUP',N'SQLDataRoot'
    xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer', 'LoginMode', N'REG_DWORD', 1
    1---Windows认证模式
    2---SQL和Windows认证模式
      

  2.   

    注意,有一个限制,就是读取不到:
    HKEY_CURRENT_USER无论怎么设置,它都读取:
    HKEY_USERS
      

  3.   

    楼上的是吗?如果用域用户启动不是System也不可以吗?回头试试。