修改sqlserver默认的路径
2012-04-28 09:26 java ee spring 阅读(1028) 评论(0) 编辑 收藏 举报/*
说明:如果查询路径返回的值是null,说明在默认安装路径下即
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA
*/
--查询用户库Data文件默认路径:
DECLARE @DefaultData VARCHAR(100)
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer',
@value_name='DefaultData',
@DefaultData=@DefaultData OUTPUT
SELECT @DefaultData
go
--查询用户库Log文件默认路径:
DECLARE @DefaultLog VARCHAR(100)
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer',
@value_name='DefaultLog',
@DefaultLog=@DefaultLog OUTPUT
SELECT @DefaultLog
go
--查询用户库备份文件默认路径:
DECLARE @BackupDirectory VARCHAR(100)
EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer',
@value_name='BackupDirectory',
@BackupDirectory=@BackupDirectory OUTPUT
SELECT @BackupDirectory
go
--修改用户库Data文件默认路径:
EXEC master..xp_regwrite
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer',
@value_name='DefaultData',
@type='REG_SZ',
@value='c:\test\data'
go
--修改用户库Log文件默认路径:
EXEC master..xp_regwrite
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer',
@value_name='DefaultLog',
@type='REG_SZ',
@value='c:\test\log'
--修改用户库备份文件默认路径:
EXEC master..xp_regwrite
@rootkey='HKEY_LOCAL_MACHINE',
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer',
@value_name='BackupDirectory',
@type='REG_SZ',
@value='D:\test\backup'
go