Script to set default data and log file folder in SQL Server 2005

Hopefully your server has separate spindles for your database’s data and log files. Here is the script to define the default directory / folder for database data and log files in Microsoft SQL Server 2005:

USE [master]
GO
EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’DefaultData’, REG_SZ, N’ChangeThisToDefaultDataDrive:\data’
GO
EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’DefaultLog’, REG_SZ, N’ChangeThisToDefaultLogDrive:\log’
GO

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.