By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,575 Members | 1,948 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,575 IT Pros & Developers. It's quick & easy.

Creating Database in OSQL Error

P: n/a
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?

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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

<ar********@hotmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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?

Jul 23 '05 #2

P: n/a
ar********@hotmail.com (ar********@hotmail.com) writes:
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
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.
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?


It certainly helps if you post the script itself.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3

P: n/a
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

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?


Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.