Solved

SQL 2008 create new Database

Posted on 2011-02-28
7
368 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
  • 3
  • 3
7 Comments
 
LVL 9

Expert Comment

by:mayank_joshi
Comment Utility
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
Comment Utility
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
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 2

Expert Comment

by:Umesh_Madap
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
When i restarted the sql server after having made the changes in DB settings, got the desired result.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now