Solved

SQL 2008 create new Database

Posted on 2011-02-28
7
371 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
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

19 Experts available now in Live!

Get 1:1 Help Now