PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > Cannot connect to database using osql with sa user
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Cannot connect to database using osql with sa user

Réponse
 
LinkBack Outils de la discussion
Vieux 13/07/2008, 19h41   #1
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Cannot connect to database using osql with sa user

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 would be greatly appreciated.

Thanks,

Rob


  Réponse avec citation
Vieux 13/07/2008, 23h55   #2
TheSQLGuru
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

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@nospam.nospam> wrote in message
news:eoIraDR5IHA.300@TK2MSFTNGP05.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 would be greatly appreciated.
>
> Thanks,
>
> Rob
>
>



  Réponse avec citation
Vieux 14/07/2008, 03h42   #3
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

The database does exist. Thanks for the drive by response.

Rob


"TheSQLGuru" <kgboles@earthlink.net> wrote in message
news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d@earthlink.co m...
> 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@nospam.nospam> wrote in message
> news:eoIraDR5IHA.300@TK2MSFTNGP05.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 would be greatly appreciated.
>>
>> Thanks,
>>
>> Rob
>>
>>

>
>



  Réponse avec citation
Vieux 14/07/2008, 06h59   #4
Uri Dimant
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

Rob
What does CreateDBObjects.sql script do? Can you connect to the NewDB via
SSMS?



"Rob Hill" <robh71@nospam.nospam> wrote in message
news:%23NMPnLV5IHA.1200@TK2MSFTNGP04.phx.gbl...
> The database does exist. Thanks for the drive by response.
>
> Rob
>
>
> "TheSQLGuru" <kgboles@earthlink.net> wrote in message
> news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d@earthlink.co m...
>> 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@nospam.nospam> wrote in message
>> news:eoIraDR5IHA.300@TK2MSFTNGP05.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 would be greatly appreciated.
>>>
>>> Thanks,
>>>
>>> Rob
>>>
>>>

>>
>>

>
>



  Réponse avec citation
Vieux 14/07/2008, 07h33   #5
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

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@iscar.co.il> wrote in message
news:%232zW04W5IHA.3784@TK2MSFTNGP06.phx.gbl...
> Rob
> What does CreateDBObjects.sql script do? Can you connect to the NewDB via
> SSMS?
>
>
>
> "Rob Hill" <robh71@nospam.nospam> wrote in message
> news:%23NMPnLV5IHA.1200@TK2MSFTNGP04.phx.gbl...
>> The database does exist. Thanks for the drive by response.
>>
>> Rob
>>
>>
>> "TheSQLGuru" <kgboles@earthlink.net> wrote in message
>> news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d@earthlink.co m...
>>> 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@nospam.nospam> wrote in message
>>> news:eoIraDR5IHA.300@TK2MSFTNGP05.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 would be greatly appreciated.
>>>>
>>>> Thanks,
>>>>
>>>> Rob
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Réponse avec citation
Vieux 14/07/2008, 07h57   #6
Uri Dimant
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

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





"Rob Hill" <robh71@nospam.nospam> wrote in message
news:OKuAdMX5IHA.1892@TK2MSFTNGP06.phx.gbl...
> 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@iscar.co.il> wrote in message
> news:%232zW04W5IHA.3784@TK2MSFTNGP06.phx.gbl...
>> Rob
>> What does CreateDBObjects.sql script do? Can you connect to the NewDB
>> via SSMS?
>>
>>
>>
>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>> news:%23NMPnLV5IHA.1200@TK2MSFTNGP04.phx.gbl...
>>> The database does exist. Thanks for the drive by response.
>>>
>>> Rob
>>>
>>>
>>> "TheSQLGuru" <kgboles@earthlink.net> wrote in message
>>> news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d@earthlink.co m...
>>>> 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@nospam.nospam> wrote in message
>>>> news:eoIraDR5IHA.300@TK2MSFTNGP05.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 would be greatly appreciated.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Rob
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Réponse avec citation
Vieux 14/07/2008, 10h37   #7
Erland Sommarskog
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

Rob Hill (robh71@nospam.nospam) writes:
> 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
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@sommarskog.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
  Réponse avec citation
Vieux 14/07/2008, 17h47   #8
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

Yes I did.

Rob

"Uri Dimant" <urid@iscar.co.il> wrote in message
news:%23vI%23pZX5IHA.1176@TK2MSFTNGP02.phx.gbl...
> Rob
> Sorry I'm ask you about , but did you make sure that you provide correct
> name of database?
>
>
>
>
>
> "Rob Hill" <robh71@nospam.nospam> wrote in message
> news:OKuAdMX5IHA.1892@TK2MSFTNGP06.phx.gbl...
>> 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@iscar.co.il> wrote in message
>> news:%232zW04W5IHA.3784@TK2MSFTNGP06.phx.gbl...
>>> Rob
>>> What does CreateDBObjects.sql script do? Can you connect to the NewDB
>>> via SSMS?
>>>
>>>
>>>
>>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>>> news:%23NMPnLV5IHA.1200@TK2MSFTNGP04.phx.gbl...
>>>> The database does exist. Thanks for the drive by response.
>>>>
>>>> Rob
>>>>
>>>>
>>>> "TheSQLGuru" <kgboles@earthlink.net> wrote in message
>>>> news:dI2dnQKbEPA65OfVnZ2dnUVZ_ovinZ2d@earthlink.co m...
>>>>> 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@nospam.nospam> wrote in message
>>>>> news:eoIraDR5IHA.300@TK2MSFTNGP05.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 would be greatly appreciated.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Rob
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Réponse avec citation
Vieux 14/07/2008, 17h54   #9
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

That's a good idea. I didn't think about that.

Here's the result.

C:\>osql.exe -S SERVER -U sa -P password
1> use NewDB
2>

The database exists, and I can enter the use command without error, but if I
specify the database on the command line

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

Thanks,

Rob

"Erland Sommarskog" <esquel@sommarskog.se> wrote in message
news:Xns9ADB6C0715EB4Yazorman@127.0.0.1...
> Rob Hill (robh71@nospam.nospam) writes:
>> 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
>
> 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@sommarskog.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



  Réponse avec citation
Vieux 14/07/2008, 18h06   #10
Russell Fields
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

Rob,

I sense your frustration, but I have a question. Did you do the following:

C:\>osql.exe -S SERVER -U sa -P password
1> use NewDB
2>
3> GO

If you did not do the GO, your "use NewDB" never executed. (Another
question, is your server using a case sensitive collation?)

RLF


"Rob Hill" <robh71@nospam.nospam> wrote in message
news:eCybjnc5IHA.2260@TK2MSFTNGP03.phx.gbl...
> That's a good idea. I didn't think about that.
>
> Here's the result.
>
> C:\>osql.exe -S SERVER -U sa -P password
> 1> use NewDB
> 2>
>
> The database exists, and I can enter the use command without error, but if
> I specify the database on the command line
>
> C:\>osql.exe -S SERVER -U sa -P password -d NewDB
> Cannot open database "NewDB" requested by the login. The login failed.
>
> Thanks,
>
> Rob
>
> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
> news:Xns9ADB6C0715EB4Yazorman@127.0.0.1...
>> Rob Hill (robh71@nospam.nospam) writes:
>>> 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
>>
>> 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@sommarskog.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

>
>



  Réponse avec citation
Vieux 14/07/2008, 18h25   #11
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

Ha! I need to go back to sleep.

The GO command gives the following error.

C:\>osql -S SERVER -U sa -P password
1> use NewDB
2> go
Msg 911, Level 16, State 1, Server SERVER, Line 1
Could not locate entry in sysdatabases for database 'NewDB'. No entry found
with
that name. Make sure that the name is entered correctly.
1>

Perhaps something is wrong with my db creation script. I have attached it
along with a cmd script to execute it.

Thanks,

Rob

"Russell Fields" <russellfields@nomail.com> wrote in message
news:%23ZPuguc5IHA.300@TK2MSFTNGP05.phx.gbl...
> Rob,
>
> I sense your frustration, but I have a question. Did you do the
> following:
>
> C:\>osql.exe -S SERVER -U sa -P password
> 1> use NewDB
> 2>
> 3> GO
>
> If you did not do the GO, your "use NewDB" never executed. (Another
> question, is your server using a case sensitive collation?)
>
> RLF
>
>
> "Rob Hill" <robh71@nospam.nospam> wrote in message
> news:eCybjnc5IHA.2260@TK2MSFTNGP03.phx.gbl...
>> That's a good idea. I didn't think about that.
>>
>> Here's the result.
>>
>> C:\>osql.exe -S SERVER -U sa -P password
>> 1> use NewDB
>> 2>
>>
>> The database exists, and I can enter the use command without error, but
>> if
>> I specify the database on the command line
>>
>> C:\>osql.exe -S SERVER -U sa -P password -d NewDB
>> Cannot open database "NewDB" requested by the login. The login failed.
>>
>> Thanks,
>>
>> Rob
>>
>> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
>> news:Xns9ADB6C0715EB4Yazorman@127.0.0.1...
>>> Rob Hill (robh71@nospam.nospam) writes:
>>>> 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
>>>
>>> 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@sommarskog.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

>>
>>

>
>







  Réponse avec citation
Vieux 14/07/2008, 18h57   #12
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

Ok - I made a mistake when typing in the database name.

The database does exist and does not error when I do

use NewDB
go

Sorry for the wrong left turn there.

Rob

"Rob Hill" <robh71@nospam.nospam> wrote in message
news:%23f2kK5c5IHA.4268@TK2MSFTNGP02.phx.gbl...
> Ha! I need to go back to sleep.
>
> The GO command gives the following error.
>
> C:\>osql -S SERVER -U sa -P password
> 1> use NewDB
> 2> go
> Msg 911, Level 16, State 1, Server SERVER, Line 1
> Could not locate entry in sysdatabases for database 'NewDB'. No entry
> found with
> that name. Make sure that the name is entered correctly.
> 1>
>
> Perhaps something is wrong with my db creation script. I have attached it
> along with a cmd script to execute it.
>
> Thanks,
>
> Rob
>
> "Russell Fields" <russellfields@nomail.com> wrote in message
> news:%23ZPuguc5IHA.300@TK2MSFTNGP05.phx.gbl...
>> Rob,
>>
>> I sense your frustration, but I have a question. Did you do the
>> following:
>>
>> C:\>osql.exe -S SERVER -U sa -P password
>> 1> use NewDB
>> 2>
>> 3> GO
>>
>> If you did not do the GO, your "use NewDB" never executed. (Another
>> question, is your server using a case sensitive collation?)
>>
>> RLF
>>
>>
>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>> news:eCybjnc5IHA.2260@TK2MSFTNGP03.phx.gbl...
>>> That's a good idea. I didn't think about that.
>>>
>>> Here's the result.
>>>
>>> C:\>osql.exe -S SERVER -U sa -P password
>>> 1> use NewDB
>>> 2>
>>>
>>> The database exists, and I can enter the use command without error, but
>>> if
>>> I specify the database on the command line
>>>
>>> C:\>osql.exe -S SERVER -U sa -P password -d NewDB
>>> Cannot open database "NewDB" requested by the login. The login failed.
>>>
>>> Thanks,
>>>
>>> Rob
>>>
>>> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
>>> news:Xns9ADB6C0715EB4Yazorman@127.0.0.1...
>>>> Rob Hill (robh71@nospam.nospam) writes:
>>>>> 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
>>>>
>>>> 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@sommarskog.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
>>>
>>>

>>
>>

>
>
>



  Réponse avec citation
Vieux 14/07/2008, 21h33   #13
Russell Fields
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

Rob,

I ran a modified version of your script and it created NewDB just fine. I
don't have another idea of what the problem might be.

RLF

"Rob Hill" <robh71@nospam.nospam> wrote in message
news:O%231n3Kd5IHA.2072@TK2MSFTNGP06.phx.gbl...
> Ok - I made a mistake when typing in the database name.
>
> The database does exist and does not error when I do
>
> use NewDB
> go
>
> Sorry for the wrong left turn there.
>
> Rob
>
> "Rob Hill" <robh71@nospam.nospam> wrote in message
> news:%23f2kK5c5IHA.4268@TK2MSFTNGP02.phx.gbl...
>> Ha! I need to go back to sleep.
>>
>> The GO command gives the following error.
>>
>> C:\>osql -S SERVER -U sa -P password
>> 1> use NewDB
>> 2> go
>> Msg 911, Level 16, State 1, Server SERVER, Line 1
>> Could not locate entry in sysdatabases for database 'NewDB'. No entry
>> found with
>> that name. Make sure that the name is entered correctly.
>> 1>
>>
>> Perhaps something is wrong with my db creation script. I have attached it
>> along with a cmd script to execute it.
>>
>> Thanks,
>>
>> Rob
>>
>> "Russell Fields" <russellfields@nomail.com> wrote in message
>> news:%23ZPuguc5IHA.300@TK2MSFTNGP05.phx.gbl...
>>> Rob,
>>>
>>> I sense your frustration, but I have a question. Did you do the
>>> following:
>>>
>>> C:\>osql.exe -S SERVER -U sa -P password
>>> 1> use NewDB
>>> 2>
>>> 3> GO
>>>
>>> If you did not do the GO, your "use NewDB" never executed. (Another
>>> question, is your server using a case sensitive collation?)
>>>
>>> RLF
>>>
>>>
>>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>>> news:eCybjnc5IHA.2260@TK2MSFTNGP03.phx.gbl...
>>>> That's a good idea. I didn't think about that.
>>>>
>>>> Here's the result.
>>>>
>>>> C:\>osql.exe -S SERVER -U sa -P password
>>>> 1> use NewDB
>>>> 2>
>>>>
>>>> The database exists, and I can enter the use command without error, but
>>>> if
>>>> I specify the database on the command line
>>>>
>>>> C:\>osql.exe -S SERVER -U sa -P password -d NewDB
>>>> Cannot open database "NewDB" requested by the login. The login failed.
>>>>
>>>> Thanks,
>>>>
>>>> Rob
>>>>
>>>> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
>>>> news:Xns9ADB6C0715EB4Yazorman@127.0.0.1...
>>>>> Rob Hill (robh71@nospam.nospam) writes:
>>>>>> 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
>>>>>
>>>>> 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@sommarskog.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
>>>>
>>>>
>>>
>>>

>>
>>
>>

>
>



  Réponse avec citation
Vieux 14/07/2008, 21h41   #14
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

After doing so, were you able to connect to the database with osql.exe?

osql -S SERVER -U sa -P password -d dbname

Thanks,

Rob

"Russell Fields" <russellfields@nomail.com> wrote in message
news:uDIFvhe5IHA.3528@TK2MSFTNGP06.phx.gbl...
> Rob,
>
> I ran a modified version of your script and it created NewDB just fine. I
> don't have another idea of what the problem might be.
>
> RLF
>
> "Rob Hill" <robh71@nospam.nospam> wrote in message
> news:O%231n3Kd5IHA.2072@TK2MSFTNGP06.phx.gbl...
>> Ok - I made a mistake when typing in the database name.
>>
>> The database does exist and does not error when I do
>>
>> use NewDB
>> go
>>
>> Sorry for the wrong left turn there.
>>
>> Rob
>>
>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>> news:%23f2kK5c5IHA.4268@TK2MSFTNGP02.phx.gbl...
>>> Ha! I need to go back to sleep.
>>>
>>> The GO command gives the following error.
>>>
>>> C:\>osql -S SERVER -U sa -P password
>>> 1> use NewDB
>>> 2> go
>>> Msg 911, Level 16, State 1, Server SERVER, Line 1
>>> Could not locate entry in sysdatabases for database 'NewDB'. No entry
>>> found with
>>> that name. Make sure that the name is entered correctly.
>>> 1>
>>>
>>> Perhaps something is wrong with my db creation script. I have attached
>>> it along with a cmd script to execute it.
>>>
>>> Thanks,
>>>
>>> Rob
>>>
>>> "Russell Fields" <russellfields@nomail.com> wrote in message
>>> news:%23ZPuguc5IHA.300@TK2MSFTNGP05.phx.gbl...
>>>> Rob,
>>>>
>>>> I sense your frustration, but I have a question. Did you do the
>>>> following:
>>>>
>>>> C:\>osql.exe -S SERVER -U sa -P password
>>>> 1> use NewDB
>>>> 2>
>>>> 3> GO
>>>>
>>>> If you did not do the GO, your "use NewDB" never executed. (Another
>>>> question, is your server using a case sensitive collation?)
>>>>
>>>> RLF
>>>>
>>>>
>>>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>>>> news:eCybjnc5IHA.2260@TK2MSFTNGP03.phx.gbl...
>>>>> That's a good idea. I didn't think about that.
>>>>>
>>>>> Here's the result.
>>>>>
>>>>> C:\>osql.exe -S SERVER -U sa -P password
>>>>> 1> use NewDB
>>>>> 2>
>>>>>
>>>>> The database exists, and I can enter the use command without error,
>>>>> but if
>>>>> I specify the database on the command line
>>>>>
>>>>> C:\>osql.exe -S SERVER -U sa -P password -d NewDB
>>>>> Cannot open database "NewDB" requested by the login. The login failed.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Rob
>>>>>
>>>>> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
>>>>> news:Xns9ADB6C0715EB4Yazorman@127.0.0.1...
>>>>>> Rob Hill (robh71@nospam.nospam) writes:
>>>>>>> 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
>>>>>>
>>>>>> 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@sommarskog.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
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>

>>
>>

>
>



  Réponse avec citation
Vieux 14/07/2008, 22h23   #15
Russell Fields
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

Rob,

Yes, no problem. I did not have your other script, of course, but just
accessing the database works fine.

Earlier I asked about your server's default collation, just in case it was
Case Sensitive, although I see no evidence in your code that you are mixing
up cases. Just another thing to think about.

Out of curiosity, are you running SQLCMD against a SQL Server 2000 database?
(I ask because your script sets 8.0 compatibility.) Nonetheless, I ran the
script against SQL Server 2000 with no problem, including the follow-on
OSQL.

RLF

"Rob Hill" <robh71@nospam.nospam> wrote in message
news:uuSISme5IHA.4448@TK2MSFTNGP05.phx.gbl...
> After doing so, were you able to connect to the database with osql.exe?
>
> osql -S SERVER -U sa -P password -d dbname
>
> Thanks,
>
> Rob
>
> "Russell Fields" <russellfields@nomail.com> wrote in message
> news:uDIFvhe5IHA.3528@TK2MSFTNGP06.phx.gbl...
>> Rob,
>>
>> I ran a modified version of your script and it created NewDB just fine.
>> I don't have another idea of what the problem might be.
>>
>> RLF
>>
>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>> news:O%231n3Kd5IHA.2072@TK2MSFTNGP06.phx.gbl...
>>> Ok - I made a mistake when typing in the database name.
>>>
>>> The database does exist and does not error when I do
>>>
>>> use NewDB
>>> go
>>>
>>> Sorry for the wrong left turn there.
>>>
>>> Rob
>>>
>>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>>> news:%23f2kK5c5IHA.4268@TK2MSFTNGP02.phx.gbl...
>>>> Ha! I need to go back to sleep.
>>>>
>>>> The GO command gives the following error.
>>>>
>>>> C:\>osql -S SERVER -U sa -P password
>>>> 1> use NewDB
>>>> 2> go
>>>> Msg 911, Level 16, State 1, Server SERVER, Line 1
>>>> Could not locate entry in sysdatabases for database 'NewDB'. No entry
>>>> found with
>>>> that name. Make sure that the name is entered correctly.
>>>> 1>
>>>>
>>>> Perhaps something is wrong with my db creation script. I have attached
>>>> it along with a cmd script to execute it.
>>>>
>>>> Thanks,
>>>>
>>>> Rob
>>>>
>>>> "Russell Fields" <russellfields@nomail.com> wrote in message
>>>> news:%23ZPuguc5IHA.300@TK2MSFTNGP05.phx.gbl...
>>>>> Rob,
>>>>>
>>>>> I sense your frustration, but I have a question. Did you do the
>>>>> following:
>>>>>
>>>>> C:\>osql.exe -S SERVER -U sa -P password
>>>>> 1> use NewDB
>>>>> 2>
>>>>> 3> GO
>>>>>
>>>>> If you did not do the GO, your "use NewDB" never executed. (Another
>>>>> question, is your server using a case sensitive collation?)
>>>>>
>>>>> RLF
>>>>>
>>>>>
>>>>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>>>>> news:eCybjnc5IHA.2260@TK2MSFTNGP03.phx.gbl...
>>>>>> That's a good idea. I didn't think about that.
>>>>>>
>>>>>> Here's the result.
>>>>>>
>>>>>> C:\>osql.exe -S SERVER -U sa -P password
>>>>>> 1> use NewDB
>>>>>> 2>
>>>>>>
>>>>>> The database exists, and I can enter the use command without error,
>>>>>> but if
>>>>>> I specify the database on the command line
>>>>>>
>>>>>> C:\>osql.exe -S SERVER -U sa -P password -d NewDB
>>>>>> Cannot open database "NewDB" requested by the login. The login
>>>>>> failed.
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Rob
>>>>>>
>>>>>> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
>>>>>> news:Xns9ADB6C0715EB4Yazorman@127.0.0.1...
>>>>>>> Rob Hill (robh71@nospam.nospam) writes:
>>>>>>>> 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
>>>>>>>
>>>>>>> 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@sommarskog.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
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Réponse avec citation
Vieux 15/07/2008, 05h13   #16
Rob Hill
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cannot connect to database using osql with sa user

The script is set tot sql 2000 compat because we have customers that are
running sql 2000.

Anyway, I did some testing and I believe that I had a typo in one of my
scripts.

Everything is working as it should.

I do appreciate your .

Thanks,

Rob

"Russell Fields" <russellfields@nomail.com> wrote in message
news:e080L%23e5IHA.2336@TK2MSFTNGP03.phx.gbl...
> Rob,
>
> Yes, no problem. I did not have your other script, of course, but just
> accessing the database works fine.
>
> Earlier I asked about your server's default collation, just in case it was
> Case Sensitive, although I see no evidence in your code that you are
> mixing up cases. Just another thing to think about.
>
> Out of curiosity, are you running SQLCMD against a SQL Server 2000
> database? (I ask because your script sets 8.0 compatibility.)
> Nonetheless, I ran the script against SQL Server 2000 with no problem,
> including the follow-on OSQL.
>
> RLF
>
> "Rob Hill" <robh71@nospam.nospam> wrote in message
> news:uuSISme5IHA.4448@TK2MSFTNGP05.phx.gbl...
>> After doing so, were you able to connect to the database with osql.exe?
>>
>> osql -S SERVER -U sa -P password -d dbname
>>
>> Thanks,
>>
>> Rob
>>
>> "Russell Fields" <russellfields@nomail.com> wrote in message
>> news:uDIFvhe5IHA.3528@TK2MSFTNGP06.phx.gbl...
>>> Rob,
>>>
>>> I ran a modified version of your script and it created NewDB just fine.
>>> I don't have another idea of what the problem might be.
>>>
>>> RLF
>>>
>>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>>> news:O%231n3Kd5IHA.2072@TK2MSFTNGP06.phx.gbl...
>>>> Ok - I made a mistake when typing in the database name.
>>>>
>>>> The database does exist and does not error when I do
>>>>
>>>> use NewDB
>>>> go
>>>>
>>>> Sorry for the wrong left turn there.
>>>>
>>>> Rob
>>>>
>>>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>>>> news:%23f2kK5c5IHA.4268@TK2MSFTNGP02.phx.gbl...
>>>>> Ha! I need to go back to sleep.
>>>>>
>>>>> The GO command gives the following error.
>>>>>
>>>>> C:\>osql -S SERVER -U sa -P password
>>>>> 1> use NewDB
>>>>> 2> go
>>>>> Msg 911, Level 16, State 1, Server SERVER, Line 1
>>>>> Could not locate entry in sysdatabases for database 'NewDB'. No entry
>>>>> found with
>>>>> that name. Make sure that the name is entered correctly.
>>>>> 1>
>>>>>
>>>>> Perhaps something is wrong with my db creation script. I have attached
>>>>> it along with a cmd script to execute it.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Rob
>>>>>
>>>>> "Russell Fields" <russellfields@nomail.com> wrote in message
>>>>> news:%23ZPuguc5IHA.300@TK2MSFTNGP05.phx.gbl...
>>>>>> Rob,
>>>>>>
>>>>>> I sense your frustration, but I have a question. Did you do the
>>>>>> following:
>>>>>>
>>>>>> C:\>osql.exe -S SERVER -U sa -P password
>>>>>> 1> use NewDB
>>>>>> 2>
>>>>>> 3> GO
>>>>>>
>>>>>> If you did not do the GO, your "use NewDB" never executed. (Another
>>>>>> question, is your server using a case sensitive collation?)
>>>>>>
>>>>>> RLF
>>>>>>
>>>>>>
>>>>>> "Rob Hill" <robh71@nospam.nospam> wrote in message
>>>>>> news:eCybjnc5IHA.2260@TK2MSFTNGP03.phx.gbl...
>>>>>>> That's a good idea. I didn't think about that.
>>>>>>>
>>>>>>> Here's the result.
>>>>>>>
>>>>>>> C:\>osql.exe -S SERVER -U sa -P password
>>>>>>> 1> use NewDB
>>>>>>> 2>
>>>>>>>
>>>>>>> The database exists, and I can enter the use command without error,
>>>>>>> but if
>>>>>>> I specify the database on the command line
>>>>>>>
>>>>>>> C:\>osql.exe -S SERVER -U sa -P password -d NewDB
>>>>>>> Cannot open database "NewDB" requested by the login. The login
>>>>>>> failed.
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Rob
>>>>>>>
>>>>>>> "Erland Sommarskog" <esquel@sommarskog.se> wrote in message
>>>>>>> news:Xns9ADB6C0715EB4Yazorman@127.0.0.1...
>>>>>>>> Rob Hill (robh71@nospam.nospam) writes:
>>>>>>>>> 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
>>>>>>>>
>>>>>>>> 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@sommarskog.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
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 05h27.