Reputation: 133
I create a database based on a mdf file. However I want to be able to store the database in a different directory.
I have,
CREATE DATABASE dbname ON (FILENAME = N'C:\sql_data\dbname.mdf')
Thanks in advance.
Upvotes: 0
Views: 352
Reputation: 4412
How you can specifiy a different locations for your database files is explained on the Technet page CREATE DATABASE .
CREATE DATABASE dbname
ON
(NAME = dbname_data, FILENAME = 'C:\temp\dbname.mdf')
If you want to do this with an already existing mdf file then you probably need to use FOR ATTACH
.
CREATE DATABASE dbname
ON (FILENAME = 'C:\temp\test\dbname.mdf')
FOR ATTACH;
It will create a new log file for you if you don't specifiy a location for the log file.
Upvotes: 1