Solved

SQL 2008 create new Database

Posted on 2011-02-28
7
377 Views
Last Modified: 2012-05-11
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
Comment
Question by:goprasad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 35004479
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
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 35004490
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
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 35004500
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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 2

Expert Comment

by:Umesh_Madap
ID: 35006133
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
 

Author Comment

by:goprasad
ID: 35023976
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
 

Accepted Solution

by:
goprasad earned 0 total points
ID: 35024075
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
 

Author Closing Comment

by:goprasad
ID: 35067717
When i restarted the sql server after having made the changes in DB settings, got the desired result.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to search for strings inside db views 4 39
Why I am having this error in my query? 2 32
Parse this column 6 34
Need to find substring in SQL 5 40
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question