Groups | Blog | Home
all groups > sql server (alternate) > december 2004 >

sql server (alternate) : Creating Database in OSQL Error


arfanameer NO[at]SPAM hotmail.com
12/26/2004 8:53:35 PM
How can I create a new database on sql server using OSQL command in
command prompt. I have the sql file for database creation and I use the
following command

C:\> osql -S servername -U sa -i db1.sql
it prompt my for password n i enter it since sa has a blank password
but after that it returns the following error.

1> 2> 3> Msg 170, Level 15, State 1, Server servername, Procedure ,
Line 2
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 2: Incorrect
syntax near 'COLLATE'.
1> 2> 3> Msg 15010, Level 16, State 1, Server servername, Procedure
sp_dboption, Line 95
[Microsoft][ODBC SQL Server Driver][SQL Server]The database
'db1' does not exist. Use sp_helpdb to show available databases
Can anyone help me on that?
Dan Guzman
12/27/2004 5:12:40 AM
This is just a guess since you didn't post the problem script but perhaps
the target is SQL Server 7 and your script was developed expecting SQL
Server 2000.

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

Erland Sommarskog
12/27/2004 8:34:07 AM
arfanameer@hotmail.com (arfanameer@hotmail.com) writes:
[quoted text, click to view]

That's bad! I strongly recommend you to change the password.

If you insist on using a blank password, -P "", saves you from the prompt.

[quoted text, click to view]

It certainly helps if you post the script itself.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
jinjja NO[at]SPAM aol.com
12/29/2004 5:36:53 AM
You need to specify the master database as your target database by specifying
-dmaster

Also, make sure your script is correct and works without problem in your QA.

Joe
MCDBA, MCSD, OCP


[quoted text, click to view]

AddThis Social Bookmark Button