Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 Creating a database with a query.

Author  Topic 

BonzoDog
Starting Member

3 Posts

Posted - 2009-04-22 : 11:52:12
Hi folks!

Please could you cast your gaze over this and tell me if thier's anything wrong with it?

CREATE DATABASE sigma ON PRIMARY (NAME = sigma_dat, FILENAME = 'D:\Source\Sigma\DEV_01\dev\Sigma\bin\Debug\sigma.mdf', SIZE = 6MB, MAXSIZE = 36MB, FILEGROWTH = 10%) LOG ON (NAME = sigma_log, FILENAME = 'D:\Source\Sigma\DEV_01\dev\Sigma\bin\Debug\sigma.ldf', SIZE = 3MB, MAXSIZE = 12MB, FILEGROWTH = 10%)

Thanks for looking!!

Cheers.

nr
SQLTeam MVY

12543 Posts

Posted - 2009-04-22 : 12:44:14
Have you tried running it?


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

BonzoDog
Starting Member

3 Posts

Posted - 2009-04-24 : 04:03:24
Yes, I've run it several times but it's behaviour confuses me!

It creates two database in that are visible in SQL Server Management Studio Express.

One named 'sigma'.
The other named 'D:\SOURCE\SIGMA\DEV_01\DEV\SIGMA\BIN\DEBUG\SIGMA.MDF'.

Why would it do this?
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2009-04-24 : 05:12:32
The database is sigma.
'D:\SOURCE\SIGMA\DEV_01\DEV\SIGMA\BIN\DEBUG\SIGMA.MDF' isn't a database - it's the file in which the database data is held.
There is also a file 'D:\Source\Sigma\DEV_01\dev\Sigma\bin\Debug\sigma.ldf' in which the log is held. These two files are attached to the sql server to create the database.

Don't know why you can see the file in management studio - it should be a property of the database.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

BonzoDog
Starting Member

3 Posts

Posted - 2009-04-24 : 05:28:15
That's exactly what I thought. It should be property of the database. Not another database altogether. Hmmm.

Interestingly, my App creates the database, then calls some functions to create the tables within the database, then falls over with :-

quote:
Unable to open the physical file "D:\Source\Sigma\DEV_01\dev\Sigma\Bin\Debug\sigma.mdf". Operating system error 32: "32(The process cannot access the file because it being used by another process.)".
An attempt to attach an auto-named database for file "D:\Source\Sigma\DEV_01\dev\Sigma\Bin\Debug\sigma.mdf" failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.


The physical file is located in the same folder as the App not on any UNC share. I'm not conciously calling any code to create another database called 'sigma'.

What's an auto-named database? I must research this some more!!!

Thanks for your replies, I do appreciate them greatly.

Think it's time to put the kettle on...
Go to Top of Page
   

- Advertisement -