sql server 2005/2008用户文件默认路径和默认备份路径修改方法
一直想把数据库的默认路径修改一下,在网上找了一下,真的发现有办法 ,
特拿 来与大家共同分享。
以下仅为参照,如果有多个实例,可能会有些许不同:
本环境是sql server 2005 standard version 64-bit 和 sql server 2008 standard version 64-bit 双实例同时安装在一个
windows server 2008 standard version 64-bit os上:
代码
windows server 2008 standard version 64-bit
sql server 2005 standard version 64-bit
查询用户库data文件默认路径:
declare @defaultdata varchar(100)
exec master..xp_regread @rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql.1\mssqlserver’,
@value_name=’defaultdata’,
@defaultdata=@defaultdata output
select @defaultdata
查询用户库log文件默认路径:
declare @defaultlog varchar(100)
exec master..xp_regread @rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql.1\mssqlserver’,
@value_name=’defaultlog’,
@defaultlog=@defaultlog output
select @defaultlog
查询用户库备份文件默认路径:
declare @backupdirectory varchar(100)
exec master..xp_regread @rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql.1\mssqlserver’,
@value_name=’backupdirectory’,
@backupdirectory=@backupdirectory output
select @backupdirectory
修改用户库data文件默认路径:
exec master..xp_regwrite
@rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql.1\mssqlserver’,
@value_name=’defaultdata’,
@type=’reg_sz’,
@value=’d:\sql2005\data’
修改用户库log文件默认路径:
exec master..xp_regwrite
@rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql.1\mssqlserver’,
@value_name=’defaultlog’,
@type=’reg_sz’,
@value=’d:\sql2005\log’
修改用户库备份文件默认路径:
exec master..xp_regwrite
@rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql.1\mssqlserver’,
@value_name=’backupdirectory’,
@type=’reg_sz’,
@value=’d:\sql2005\dbbak’
代码
windows server 2008 standard version 64-bit
sql server 2008 standard version 64-bit
查询用户库data文件默认路径:
declare @defaultdata varchar(100)
exec master..xp_regread @rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql10.sql2008\mssqlserver’,
@value_name=’defaultdata’,
@defaultdata=@defaultdata output
select @defaultdata
查询用户库log文件默认路径:
declare @defaultlog varchar(100)
exec master..xp_regread @rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql10.sql2008\mssqlserver’,
@value_name=’defaultlog’,
@defaultlog=@defaultlog output
select @defaultlog
查询用户库备份文件默认路径:
declare @backupdirectory varchar(100)
exec master..xp_regread @rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql10.sql2008\mssqlserver’,
@value_name=’backupdirectory’,
@backupdirectory=@backupdirectory output
select @backupdirectory
修改用户库data文件默认路径:
exec master..xp_regwrite
@rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql10.sql2008\mssqlserver’,
@value_name=’defaultdata’,
@type=’reg_sz’,
@value=’d:\sql2008\data’
修改用户库log文件默认路径:
exec master..xp_regwrite
@rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql10.sql2008\mssqlserver’,
@value_name=’defaultlog’,
@type=’reg_sz’,
@value=’d:\sql2008\log’
修改用户库备份文件默认路径:
exec master..xp_regwrite
@rootkey=’hkey_local_machine’,
@key=’software\microsoft\microsoft sql server\mssql10.sql2008\mssqlserver’,
@value_name=’backupdirectory’,
@type=’reg_sz’,
@value=’d:\sql2008\dbbak’