|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 > > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 >> >> > > |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 >>> >>> >> >> > > |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 >>>> >>>> >>> >>> >> >> > > |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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 >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
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 >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
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 > > |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
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 >> >> > > |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
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 >>> >>> >> >> > > > |
|
|
|
#13 |
|
Messages: n/a
Hébergeur: |
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 >>>> >>>> >>> >>> >> >> >> > > |
|
|
|
#14 |
|
Messages: n/a
Hébergeur: |
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 >>>>> >>>>> >>>> >>>> >>> >>> >>> >> >> > > |
|
|
|
#15 |
|
Messages: n/a
Hébergeur: |
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 >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> >> >> > > |
|
|
|
#16 |
|
Messages: n/a
Hébergeur: |
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 >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > > |
|
![]() |
| Outils de la discussion | |
|
|