手动方法:
使用SQL语句:
USE [master]
GO
DECLARE @Reg_Key NVARCHAR(40) = N"HKEY_LOCAL_MACHINE"
DECLARE @Reg_Soft_Path NVARCHAR(100) = N"SoftwareMicrosoftMSSQLServerMSSQLServer"
-- 更改数据文件的默认位置
EXEC xp_instance_regwrite
@Reg_Key,
@Reg_Soft_Path,
N"DefaultData",
REG_SZ,
N"E:MSSQLData"
-- 更改日志文件的默认位置
EXEC xp_instance_regwrite
@Reg_Key,
@Reg_Soft_Path,
N"DefaultLog",
REG_SZ,
N"E:MSSQLLog"
-- 更改备份的默认位置
EXEC xp_instance_regwrite
@Reg_Key,
@Reg_Soft_Path,
N"BackupDirectory",
REG_SZ,
N"E:MSSQLBackup"
GO
Source Code
然后,我们可以打开windows注册表查看: