Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change where databases are created in SQL Server Management Studio? [closed]

By default, all new databases are created on C:\. I need them to be created on E:\. My first instinct was to move the database files for the model database, but SSMS is not giving me the option to detach it.

So, my question is, is there a way to set up the server so that all of the new databases are created on E:\ by default?

like image 679
DForck42 Avatar asked Sep 13 '10 15:09

DForck42


1 Answers

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.

alt text

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 
like image 193
Joe Stefanelli Avatar answered Oct 11 '22 01:10

Joe Stefanelli