Search This Blog

Wednesday, August 4, 2010

Query to change default data and log path

This query modifies the registry value of a data and log folder path for default instance of SQL Server and for named instance "MSSQLServer" has to be replaced with instance name

USE master
GO

EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', REG_SZ, N'D:\SQLDB\DATA'
GO

EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog', REG_SZ, N'Z:\SQLDB\LOG'
GO

No comments: