Link to home
Start Free TrialLog in
Avatar of APHComputersLtd
APHComputersLtdFlag for United Kingdom of Great Britain and Northern Ireland

asked on

[Microsoft][ODBC SQL Server Driver][SQL server]Cannot open database requested by the login. the login failed

Hi Dear Experts, I am facing the following error: [Microsoft][ODBC SQL Server Driver][SQL server]Cannot open database requested by the login. the login failed when i call the following command in sql2005, bcp [servername].[dbo].[tablename] out c:\T1Export.csv  -w    -t\t -S machinename-U sa -Ppassword.
the command works fine on my machine, but not on the customer site.
my machine is a development machine but on the customer machine i just have sql server ,no MS office and no MDAC. Do i need to install any thing. I very much appriciate any help. thanks.
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

It cannot work if the command is really "bcp [servername].[dbo].[tablename] out ..." and the database name is different from sarvername.

It should be:
"bcp [databasename].[dbo].[tablename] out ..."

You may also look if the sa user is enabled.
Avatar of APHComputersLtd

ASKER

Hi Pcelba,
Thanks for your reply, I noticed that i had typing mistake in my question, it is databasename which i used after bcp.
re the sa user, i can  login using sql authent. by user sa although when you look at the security\users node under the specified database i have users such as dbo,buildin administrators,,,,, but not sa explicityly. but the dbo loginnn. although i have the user sa declared under the selected server, please find attached snapshot. Hope this could give you some ideas about where the problem is.
Many thanks.
expert.bmp
SOLUTION
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The sa user doesn't have a red arrow  next to it and it is enabled.
but i just come acoross the following :
When i run BCP master..sysobjects out c:\sysobjects.txt -c -t, -T , it works and creates the file but if i run bcp [HKTest].[dbo].[tbfinalreport] out c:\ScheduleReport.csv  -c -t, -T , it does come up with a login failure. please see attached

expert2.bmp
I forgot to tell you that i am doing RemoteDesktop to the customer site. As you probably noticed the bcp command that doesn;t have any -T switch does ask for a password but no matther whether i type in the windows administrator password or sql password it doesn't like it. I am sure it is something to do with the login set up on this server, please help . Thanks.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Interesting. Above syntax should be equivalent for SQL Server. But it is not true for bcp utility... I am learning instead of helping.

So, please assign your last comment as the accepted answer to preserve it for future references.

And thanks!