473,396 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating Database in OSQL Error

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
3 6108
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ajay Garg | last post by:
I am running the following OSQL command and capturing the return code for the error .Whenver i have an error like server not exists or uable to login I get a return code of 1 for the...
5
by: great_googley_moogley | last post by:
Greetings, I am in the process of installing a SQL database at a customer location. I have determined that there are 3 ways to do this, and I wanted to know which is the best of the 3. 1...
4
by: Bruce | last post by:
I need to create a stored procedure in the master database that can access info to dynamically create a view in another database. It doesn't seem like it should be very hard, but I can't get it to...
2
by: Santo Santis | last post by:
How can I make an .exe file that can insert data automatically in a SQLServer database, I can do it in C, but how can I connect to SQLServer and execute a query. All data that I have to insert...
2
by: arfanameer | last post by:
I have to create database usign OSQL. i am usin a command like this C:> osql -E -i db1.sql But it doesnt create database and returns error saying user login failed for administrator whereas I...
10
by: John A Fotheringham | last post by:
I'm trying to write a procedure that having created a new database, will then create within that new database all the tables and procedures that go with it. In doing this I'm hitting the problem...
1
by: And | last post by:
I everyone! I'm a new asp.net user and I'm trying to run some sample files from de msdn database and most of them use the pubs database. My problem is that although I see the pubs database in...
6
by: Ober | last post by:
I'm having trouble with my security model, Application_Start, and accessing my database. My ASP.NET app is only going to be running in an intranet environment (not on the public Internet). ...
1
by: Tina888 | last post by:
I am running osql command that goes and grabs files from my folder and runs one script at a time and loops though all the files in that folder. Most of the files and simple inserts or creation of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.