![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
|
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 |
#5
| |||
| |||
|
|
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 |
#6
| |||
| |||
|
|
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 |
#7
| |||
| |||
|
|
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 |
#8
| |||
| |||
|
|
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 |
#9
| |||
| |||
|
|
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 |
#10
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |