dbTalk Databases Forums  

Cannot connect to database using osql with sa user

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss Cannot connect to database using osql with sa user in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #41  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 12:57 AM






Rob
Sorry I'm ask you about , but did you make sure that you provide correct
name of database?





"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote

Quote:
Uri,

The script creates tables and stored procedures. Even if I don't run the
script, I can't connect to the database with osql.exe.

I am able to access the database with the SQL Management Studio.

Rob


"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:%232zW04W5IHA.3784 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Rob
What does CreateDBObjects.sql script do? Can you connect to the NewDB
via SSMS?



"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:%23NMPnLV5IHA.1200 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
The database does exist. Thanks for the drive by response.

Rob


"TheSQLGuru" <kgboles (AT) earthlink (DOT) net> wrote in message
news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d (AT) earthlink (DOT) com...
You cannot connect specifying a database to connect to which does not
exist (yet).

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:eoIraDR5IHA.300 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
I am writing a script to create a database for out application.
Currently the app attaches an mdf and ldf, but I don't like that
solution.

I have a script that creates a database using sqlcmd.exe and I pass
variables to it using the -v option. It works fine.
When I attempt to run a second script via osql.exe it fails with the
following error:

C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I omit the input file, I get the same error:
C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I connect to a database other than the one I just created with the
script, it works:
C:\>osql.exe -S SERVER -U sa -P password -d ExistingDB
1> quit
C:\

I'm at a loss here. I thought the sa account was supreme.

Any help would be greatly appreciated.

Thanks,

Rob













Reply With Quote
  #42  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 12:57 AM






Rob
Sorry I'm ask you about , but did you make sure that you provide correct
name of database?





"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote

Quote:
Uri,

The script creates tables and stored procedures. Even if I don't run the
script, I can't connect to the database with osql.exe.

I am able to access the database with the SQL Management Studio.

Rob


"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:%232zW04W5IHA.3784 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Rob
What does CreateDBObjects.sql script do? Can you connect to the NewDB
via SSMS?



"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:%23NMPnLV5IHA.1200 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
The database does exist. Thanks for the drive by response.

Rob


"TheSQLGuru" <kgboles (AT) earthlink (DOT) net> wrote in message
news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d (AT) earthlink (DOT) com...
You cannot connect specifying a database to connect to which does not
exist (yet).

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:eoIraDR5IHA.300 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
I am writing a script to create a database for out application.
Currently the app attaches an mdf and ldf, but I don't like that
solution.

I have a script that creates a database using sqlcmd.exe and I pass
variables to it using the -v option. It works fine.
When I attempt to run a second script via osql.exe it fails with the
following error:

C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I omit the input file, I get the same error:
C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I connect to a database other than the one I just created with the
script, it works:
C:\>osql.exe -S SERVER -U sa -P password -d ExistingDB
1> quit
C:\

I'm at a loss here. I thought the sa account was supreme.

Any help would be greatly appreciated.

Thanks,

Rob













Reply With Quote
  #43  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 12:57 AM



Rob
Sorry I'm ask you about , but did you make sure that you provide correct
name of database?





"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote

Quote:
Uri,

The script creates tables and stored procedures. Even if I don't run the
script, I can't connect to the database with osql.exe.

I am able to access the database with the SQL Management Studio.

Rob


"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:%232zW04W5IHA.3784 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Rob
What does CreateDBObjects.sql script do? Can you connect to the NewDB
via SSMS?



"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:%23NMPnLV5IHA.1200 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
The database does exist. Thanks for the drive by response.

Rob


"TheSQLGuru" <kgboles (AT) earthlink (DOT) net> wrote in message
news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d (AT) earthlink (DOT) com...
You cannot connect specifying a database to connect to which does not
exist (yet).

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:eoIraDR5IHA.300 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
I am writing a script to create a database for out application.
Currently the app attaches an mdf and ldf, but I don't like that
solution.

I have a script that creates a database using sqlcmd.exe and I pass
variables to it using the -v option. It works fine.
When I attempt to run a second script via osql.exe it fails with the
following error:

C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I omit the input file, I get the same error:
C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I connect to a database other than the one I just created with the
script, it works:
C:\>osql.exe -S SERVER -U sa -P password -d ExistingDB
1> quit
C:\

I'm at a loss here. I thought the sa account was supreme.

Any help would be greatly appreciated.

Thanks,

Rob













Reply With Quote
  #44  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 12:57 AM



Rob
Sorry I'm ask you about , but did you make sure that you provide correct
name of database?





"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote

Quote:
Uri,

The script creates tables and stored procedures. Even if I don't run the
script, I can't connect to the database with osql.exe.

I am able to access the database with the SQL Management Studio.

Rob


"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:%232zW04W5IHA.3784 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Rob
What does CreateDBObjects.sql script do? Can you connect to the NewDB
via SSMS?



"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:%23NMPnLV5IHA.1200 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
The database does exist. Thanks for the drive by response.

Rob


"TheSQLGuru" <kgboles (AT) earthlink (DOT) net> wrote in message
news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d (AT) earthlink (DOT) com...
You cannot connect specifying a database to connect to which does not
exist (yet).

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:eoIraDR5IHA.300 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
I am writing a script to create a database for out application.
Currently the app attaches an mdf and ldf, but I don't like that
solution.

I have a script that creates a database using sqlcmd.exe and I pass
variables to it using the -v option. It works fine.
When I attempt to run a second script via osql.exe it fails with the
following error:

C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I omit the input file, I get the same error:
C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I connect to a database other than the one I just created with the
script, it works:
C:\>osql.exe -S SERVER -U sa -P password -d ExistingDB
1> quit
C:\

I'm at a loss here. I thought the sa account was supreme.

Any help would be greatly appreciated.

Thanks,

Rob













Reply With Quote
  #45  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 12:57 AM



Rob
Sorry I'm ask you about , but did you make sure that you provide correct
name of database?





"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote

Quote:
Uri,

The script creates tables and stored procedures. Even if I don't run the
script, I can't connect to the database with osql.exe.

I am able to access the database with the SQL Management Studio.

Rob


"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:%232zW04W5IHA.3784 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Rob
What does CreateDBObjects.sql script do? Can you connect to the NewDB
via SSMS?



"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:%23NMPnLV5IHA.1200 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
The database does exist. Thanks for the drive by response.

Rob


"TheSQLGuru" <kgboles (AT) earthlink (DOT) net> wrote in message
news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d (AT) earthlink (DOT) com...
You cannot connect specifying a database to connect to which does not
exist (yet).

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:eoIraDR5IHA.300 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
I am writing a script to create a database for out application.
Currently the app attaches an mdf and ldf, but I don't like that
solution.

I have a script that creates a database using sqlcmd.exe and I pass
variables to it using the -v option. It works fine.
When I attempt to run a second script via osql.exe it fails with the
following error:

C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I omit the input file, I get the same error:
C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I connect to a database other than the one I just created with the
script, it works:
C:\>osql.exe -S SERVER -U sa -P password -d ExistingDB
1> quit
C:\

I'm at a loss here. I thought the sa account was supreme.

Any help would be greatly appreciated.

Thanks,

Rob













Reply With Quote
  #46  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 12:57 AM



Rob
Sorry I'm ask you about , but did you make sure that you provide correct
name of database?





"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote

Quote:
Uri,

The script creates tables and stored procedures. Even if I don't run the
script, I can't connect to the database with osql.exe.

I am able to access the database with the SQL Management Studio.

Rob


"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:%232zW04W5IHA.3784 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Rob
What does CreateDBObjects.sql script do? Can you connect to the NewDB
via SSMS?



"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:%23NMPnLV5IHA.1200 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
The database does exist. Thanks for the drive by response.

Rob


"TheSQLGuru" <kgboles (AT) earthlink (DOT) net> wrote in message
news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d (AT) earthlink (DOT) com...
You cannot connect specifying a database to connect to which does not
exist (yet).

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"Rob Hill" <robh71 (AT) nospam (DOT) nospam> wrote in message
news:eoIraDR5IHA.300 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
I am writing a script to create a database for out application.
Currently the app attaches an mdf and ldf, but I don't like that
solution.

I have a script that creates a database using sqlcmd.exe and I pass
variables to it using the -v option. It works fine.
When I attempt to run a second script via osql.exe it fails with the
following error:

C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I omit the input file, I get the same error:
C:\>osql.exe -S SERVER -U sa -P password -d NewDB -i
2_CreateDBObjects.sql
Cannot open database "NewDB" requested by the login. The login failed.

If I connect to a database other than the one I just created with the
script, it works:
C:\>osql.exe -S SERVER -U sa -P password -d ExistingDB
1> quit
C:\

I'm at a loss here. I thought the sa account was supreme.

Any help would be greatly appreciated.

Thanks,

Rob













Reply With Quote
  #47  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 03:37 AM



Rob Hill (robh71 (AT) nospam (DOT) nospam) writes:
Quote:
The database does exist. Thanks for the drive by response.
The error message you indicates that the database is not accessible. This
could be because it does not exist, or beause it is in single-user mode.

Since we don't see your system and your actual command-line, we cannot help
you much more than this. But you could try:

OSQL -S SERVER -U sa -P pwd

Then at this prompt type USE followed by space. Then you copy and paste the
database name from the failed command line, press return and then go, and
see what error message you may get now.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #48  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 03:37 AM



Rob Hill (robh71 (AT) nospam (DOT) nospam) writes:
Quote:
The database does exist. Thanks for the drive by response.
The error message you indicates that the database is not accessible. This
could be because it does not exist, or beause it is in single-user mode.

Since we don't see your system and your actual command-line, we cannot help
you much more than this. But you could try:

OSQL -S SERVER -U sa -P pwd

Then at this prompt type USE followed by space. Then you copy and paste the
database name from the failed command line, press return and then go, and
see what error message you may get now.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #49  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 03:37 AM



Rob Hill (robh71 (AT) nospam (DOT) nospam) writes:
Quote:
The database does exist. Thanks for the drive by response.
The error message you indicates that the database is not accessible. This
could be because it does not exist, or beause it is in single-user mode.

Since we don't see your system and your actual command-line, we cannot help
you much more than this. But you could try:

OSQL -S SERVER -U sa -P pwd

Then at this prompt type USE followed by space. Then you copy and paste the
database name from the failed command line, press return and then go, and
see what error message you may get now.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #50  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: Cannot connect to database using osql with sa user - 07-14-2008 , 03:37 AM



Rob Hill (robh71 (AT) nospam (DOT) nospam) writes:
Quote:
The database does exist. Thanks for the drive by response.
The error message you indicates that the database is not accessible. This
could be because it does not exist, or beause it is in single-user mode.

Since we don't see your system and your actual command-line, we cannot help
you much more than this. But you could try:

OSQL -S SERVER -U sa -P pwd

Then at this prompt type USE followed by space. Then you copy and paste the
database name from the failed command line, press return and then go, and
see what error message you may get now.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.