When I create a new database, by default the files are saved to c:\program files...
but I would like them by default to be saved into a different location WITHOUT having to adjust anything. Is there a way to have this done by default?
Perhaps there's some stored system procedure that I would have to change?
Microsoft SQL Server stores two types of data files in default directories on respective systems, which are known as Master Database Files and Log Database Files, and abbreviated as MDF and LDF data files. Both these files are primarily available in the SQL Server environment.
In SSMS, right click on the server and choose "Properties". On the "Database Settings" page of the Server Properties window, specify your new locations for data and log files.
You could also do this with T-SQL by writing directly to the registry:
USE [master]
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', REG_SZ, N'E:\YourData'
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog', REG_SZ, N'E:\YourLogs'
GO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With