修改SQL Server 2005/2008新建数据库文件及备份文件的默认保存路径

查询新建数据库Data文件默认保存路径(若查询结果为NULL,则表示未进行配置,下同):

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=’G:\DB\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=’G:\DB\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=’G:\DB\Bak’

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>