My Favorite Blogs

Wednesday, January 27, 2010

How to Set the default database and log directories on MS SQL Instance using T-SQL commands

--Run the following script on Query Analyzer


USE master

--For Data files
EXEC xp_instance_regwrite
    N'HKEY_LOCAL_MACHINE',
    N'Software\Microsoft\MSSQLServer\MSSQLServer',
    N'DefaultData',
    REG_SZ,
    N'H:\sql\data'


--For Log  files
EXEC xp_instance_regwrite
    N'HKEY_LOCAL_MACHINE',
    N'Software\Microsoft\MSSQLServer\MSSQLServer',
    N'DefaultLog',
    REG_SZ,
    N'O:\sql\Log'

No comments:

Post a Comment