Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database create error

Status
Not open for further replies.

aking

Technical User
Aug 11, 2002
112
GB
Hi, am new to sql server so apologies if this is a really simple question.

Been supplied with script by software suppliers (who are pretty awful about database support) so i wanna check i'm not doing something stupid before i query their script.

CREATE DATABASE dbase ON ( NAME = Dbase_dat, FILENAME = '%~1\Dbase.mdf', SIZE = 500, MAXSIZE = UNLIMITED, FILEGROWTH = 50 ) LOG ON ( NAME = 'Dbase_log', FILENAME = '%~1\Dbaselog.ldf', SIZE = 300MB, MAXSIZE = UNLIMITED, FILEGROWTH = 100MB )

and the result is:
Msg 5105, Level 16, State 2, Line 11
A file activation error occurred. The physical file name '%~1\Dbase.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Msg 1802, Level 16, State 1, Line 11
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

Got this error when executing the script in SQL Server Studio Manger.
Is this error caused by sqlserver not understanding the pathname? I don't understand what path '%~1\Dbase.mdf' is supposed to be - and i would have thought i should add a path name there - but i am not supposed to edit these scripts.

Does anyone know the cause of this error?
I am running SQL Server 2005 sp2 (brand new installation).
Running on Windows Server 2003 R2 SP2 x64
 
Yes, it is because there is no proper path etc. in the script you have posted.

Try the below, replacing "mydb" and the "c:\mypath\mydbxxxxx" with whatever is relevant naming / locations for your DB.

Code:
CREATE DATABASE Mydb ON ( NAME = Mydb_dat,  FILENAME = 'C:\mypath\Mydb.mdf',  SIZE = 500, MAXSIZE = UNLIMITED, FILEGROWTH = 50 ) LOG ON ( NAME = 'Mydb_log', FILENAME = 'C:\mypath\Mydblog.ldf', SIZE = 300MB, MAXSIZE = UNLIMITED, FILEGROWTH = 100MB )

HTH,

M.
 
Change %~1 to the installation path of SQL (or where ever you want to put the db files). It is probably C:\Program Files\Microsoft SQL Server.

-If it ain't broke, break it and make it better.
 
Thanks guys.
Putting in the path fixed it.
Database online this morning :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top