• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

SQL 2008 create new Database

Hello experts,

I have a SQL server with SAN attached storage and allocated letter D:\Data and L:\Log and set them in the default DB settings after installing SQL 2008.

When running script to create new DB, mdf and ldf files are never created inside Data and Log folders instead they are created in the roor of D and L, I have checked the permissions.

Please advise, what is stopping from creating mdf and ldf inside the sub-folders?

Thanks and Regards.
0
goprasad
Asked:
goprasad
  • 3
  • 3
1 Solution
 
mayank_joshiCommented:
try the following script:-

CREATE DATABASE [NewData] ON  PRIMARY 
( NAME = N'NewData', FILENAME = N'D:\Data\NewData.mdf\NewData.mdf' , SIZE = 2048KB , FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'NewData_log', FILENAME = N'L:\Data\NewData.ldf\NewData_log.ldf' , SIZE = 6144KB , FILEGROWTH = 10%)
GO

Open in new window

0
 
mayank_joshiCommented:
corrected:-

CREATE DATABASE [NewData] ON  PRIMARY 
( NAME = N'NewData', FILENAME = N'D:\Data\NewData.mdf' , SIZE = 2048KB , FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'NewData_log', FILENAME = N'L:\Log\NewData_log.ldf' , SIZE = 6144KB , FILEGROWTH = 10%)
GO

Open in new window

0
 
mayank_joshiCommented:
you may ignore the default values of size and filegrowth:-

CREATE DATABASE [NewData] ON  PRIMARY 
( NAME = N'NewData', FILENAME = N'D:\Data\NewData.mdf' )
 LOG ON 
( NAME = N'NewData_log', FILENAME = N'L:\Log\NewData_log.ldf' )
GO

Open in new window


but the folders Data and Log must be created in drives D: and L: respectively before executing this script.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Umesh_MadapCommented:
CREATE DATABASE [TEST_DB] ON  PRIMARY
( NAME = N'TEST_DB', FILENAME = N'D:\Data\TEST_DB.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB )
 LOG ON
( NAME = N'TEST_DB_log', FILENAME = N'L:\Log\TEST_DB_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)
GO

use can use the above script and also u can set the initial size of the database and file growth these two parameters you can set as per your requirements.

please let me know if yo need any further clarification.
0
 
goprasadAuthor Commented:
This is the new SQL box I built with sql2005 and in database settings for the instance, I have allocated D: and L: for data and log respectively, so that when I create a new DB, the mdf and ldf should go and sit by default in D and L. But this is not the case, for ex: when I execute the command below, the mdf/ldf are located in C:\
Use master
go
create database test32
go

I have attached screenshots for reference. Want to know why the default location for mdf and ldf are not used.

Please advise. Drives Drives Data
0
 
goprasadAuthor Commented:
I figured it out, when you make a changes in Database settings, sql server needs a restart. When I then executed the same command to create new DB, it did use def locations for mdf and ldf
0
 
goprasadAuthor Commented:
When i restarted the sql server after having made the changes in DB settings, got the desired result.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now