SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Create Database


Create Database

Author
Message
Toreador
Toreador
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3800 Visits: 8123
Lynn Pettis (5/13/2009)
If you take a few minutes to read CREATE DATABASE in BOL you'd see that it is required that the directory structure already be in place, therefore for this question it must be assumed that requirement was already met. Based on that, the statement works.



Wouldn't an equally valid assumption be that the requirement was not already met (as the path does not exist in a standard installation), and hence that the statement does not work?

Anyway, I'll quit whining as I'm too ignorant to think up any questions of my own Ermm
Rachel Byford
Rachel Byford
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1940 Visits: 968
I don't dare submit a question - I'd hate to be on the receiving end of all these complaints! w00t

And besides, the only questions I can think of are ones to which I don't yet know the answer... ;-)

I repeat from a post on a previous thread though - I love SSC.
Steve Jones
Steve Jones
SSC Guru
SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)

Group: Administrators
Points: 142386 Visits: 19424
The requirement for the path to exist could be a question. That's certainly valid, but this question asked "will this work" (originally) and then "can this work" (edited). In either case, given the right situation, it will (and can).

It's a simple yes/no, so you would lean yes. If it can never work, as in

CREATE DATABASE MyDB on SAN="\\mysan\mymount"



Then you would lean no.

Feel free to try a question. they don't automatically go out. I look over them and will send them back if they're too vague. So definitely I make mistakes on some of these as well.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
John.Sansom
John.Sansom
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1781 Visits: 1558
Lynn Pettis (5/13/2009)
John Sansom (5/13/2009)
Hi,

This of course does not work, unless the folder structures are in place on the system in question. Otherwise errors of the form below are returned.



Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "C:\mssql\MYTEST.doc" failed with the operating system error 2(The system cannot find the file specified.).
Msg 1802, Level 16, State 1, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.


Yep, as several others have already mentioned. If you take a few minutes to read CREATE DATABASE in BOL you'd see that it is required that the directory structure already be in place, therefore for this question it must be assumed that requirement was already met. Based on that, the statement works.



I did actually attempt to remove the post almost immediately after posting it, having only subsequently then noticed the prior pages comments, so yes my mistake.

For some reason though, I am unable to remove the post.


John Sansom (@sqlBrit) | www.johnsansom.com
Steve Jones
Steve Jones
SSC Guru
SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)SSC Guru (142K reputation)

Group: Administrators
Points: 142386 Visits: 19424
We don't allow post deletions. We do allow editing.

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
John.Sansom
John.Sansom
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1781 Visits: 1558
Steve Jones - Editor (5/13/2009)
We don't allow post deletions. We do allow editing.


duly noted, thanks.


John Sansom (@sqlBrit) | www.johnsansom.com
brewmanz
brewmanz
Right there with Babe
Right there with Babe (759 reputation)Right there with Babe (759 reputation)Right there with Babe (759 reputation)Right there with Babe (759 reputation)Right there with Babe (759 reputation)Right there with Babe (759 reputation)Right there with Babe (759 reputation)Right there with Babe (759 reputation)

Group: General Forum Members
Points: 759 Visits: 406
I'm surprised that this is treated as a T-SQL issue rather than Administration, as I regard database space creation as Admin.

To me, T-SQL stands for 'Transaction(al) SQL', and I don't see much in the way of transactions for space creation. Or is this something that people do in transactions & then roll back?
Dugi
Dugi
SSCarpal Tunnel
SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)

Group: General Forum Members
Points: 4606 Visits: 3511
Yep I said No, but if you think little bit more about creating DB details, you will said yes...the default for data file was mdf, ndf and for log files was ldf...but you can put any format doc, pdf, mp3 sure that it is not preferable couz you can confuse yourself with the files. On the other hand it is very tricky - security thing!

HeheHehe

============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Brian Ferguson
Brian Ferguson
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1183 Visits: 105
Code as indicated does not work for me either.
By adding a c:\mssql folder (did not have one on my system) AND changing the the data file folder to c:\mssql, it works.

Create Database Mytestdb
on
(

name ='Mytest_1',

Filename= 'C:\mssql\MyTEST.mp3',

size = 5000 KB
)
log on
(
name ='MyTest_2',

Filename= 'C:\mssql\MYTEST.doc',

size= 512 kb
)

But the code as written in the question will not work.



Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)

Group: General Forum Members
Points: 92015 Visits: 38954
Brian Ferguson (6/10/2009)
Code as indicated does not work for me either.
By adding a c:\mssql folder (did not have one on my system) AND changing the the data file folder to c:\mssql, it works.

Create Database Mytestdb
on
(

name ='Mytest_1',

Filename= 'C:\mssql\MyTEST.mp3',

size = 5000 KB
)
log on
(
name ='MyTest_2',

Filename= 'C:\mssql\MYTEST.doc',

size= 512 kb
)

But the code as written in the question will not work.


If you read BOL, you will see that for CREATE DATABASE, the directory structure must already exist. Therefor, if you are going to run this code, you should have already ensured that the directory structure you are using in the CREATE DATABASE statement already exists. Based on that, the code works. Regardless if the code failed on your system when you attempted to run it.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search