Before we modify the database storage path, we have to do an analysis of the database, we need to know his storage mode! Database The default path is saved in the registration table, we can modify the registry through Xp_instance_regwrite, the following is the way I tried on the 3A network server, you can look at:
First, change the data file default storage path:
EXEC Xp_instance_regwrite
@rootkey = ' HKEY_LOCAL_MACHINE ',
@key = ' Software\microsoft\mssqlserver\mssqlserver ',
@value_name = ' Defaultdata ',
@type =REG_SZ,
@value = ' D:\MSSQL\Data '
Second, change the log file default storage path:
EXEC Master. Xp_instance_regwrite
@rootkey = ' HKEY_LOCAL_MACHINE ',
@key = ' Software\microsoft\mssqlserver\mssqlserver ',
@value_name = ' Defaultlog ',
@type =REG_SZ,
@value = ' D:\MSSQL\Data '
MSSQL How to modify the default database storage path