>  기사  >  데이터 베이스  >  SQL Server 2005/2008 用户数据库文件默认路径和默认备份路径修

SQL Server 2005/2008 用户数据库文件默认路径和默认备份路径修

WBOY
WBOY원래의
2016-06-07 18:00:051360검색

本环境是SQL Server 2005 Standard Version 64-bit 和 SQL Server 2008 Standard Version 64-bit 双实例同时安装在一个Windows Server 2008 Standard Version 64-bit OS上

以下仅为参照,如果有多个实例,可能会有些许不同:
本环境是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'

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.