一直想把數據庫的默認路徑修改一下,在網上找了一下,真的發現有辦法 , 數據庫
特拿 來與你們共同分享。 spa
如下僅爲參照,若是有多個實例,可能會有些許不一樣:
本環境是SQL Server 2005 Standard Version 64-bit 和 SQL Server 2008 Standard Version 64-bit 雙實例同時安裝在一個
Windows Server 2008 Standard Version 64-bit OS上: it
代碼
Windows Server 2008 Standard Version 64-bit
SQL Server 2005 Standard Version 64-bit io
查詢用戶庫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 ast
查詢用戶庫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'