The stored procedure "master.sys.xp_instance_regwrite" is not documented in SQL Server Books Online (BOL), but is usefull. In general the syntax isEXECUTE [master].[sys].[xp_instance_regwrite]
@rootkey = N'<name of root key>'
,@key = N'<key name>'
,@value_name = N'<key name value>'
,@type = N'<key type>'
,@value = <key value>;
For example the number of SQL Server Errorlog files can be updated by the statementEXECUTE [master].[sys].[xp_instance_regwrite]
@rootkey = N'HKEY_LOCAL_MACHINE'
,@key = N'Software\Microsoft\MSSQLServer\MSSQLServer'
,@value_name = N'NumErrorLogs'
,@type = N'REG_DWORD'
,@value = 42;
The parameter @type takes a value without N'' around (@type = <key type>), but I like the Unicode framing. This way I try to avoid difficulties when building the values outside the call.
本文介绍了 SQL Server 中未被官方文档详细记录的存储过程 xp_instance_regwrite 的使用方法,该存储过程可用于更新 SQL Server 相关的注册表设置,例如调整错误日志文件的数量。需要注意的是,操作注册表可能带来风险,因此使用时应谨慎。

308

被折叠的 条评论
为什么被折叠?



