[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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
APHComputersLtdAuthor Commented:
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.
User dbo uses sa login. You have to look at logins for the whole SQL Server. If the sa login has the red arrow near its name (like user guest on your snapshot picture) then it is disabled. Double click the sa login to view/change its properties (like disabled status, password, etc.). The standard setting for sa login is "disabled" due to the security resons.

Also look at User mappings page on sa properties window. sa login should have mapped your database.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

APHComputersLtdAuthor Commented:
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

APHComputersLtdAuthor Commented:
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.
If the user who has trusted login (-T parameter) allowed can access master database then it must be possible to allow him other database usage.

You have to do it on Server level: Security - Logins. Double click on the login which is logged on the remote computer and on the "User mappings" page map the hktest database to him.
APHComputersLtdAuthor Commented:
I figured it out but i am not sure why its acting like this, in the command below if we remove the pair of brackets around the database name and leave the rest it works.
so it should be  bcp HKTest.[dbo].[tbfinalreport] out c:\ScheduleReport.csv  -c -t, -T  
instead of  bcp [HKTest].[dbo].[tbfinalreport] out c:\ScheduleReport.csv  -c -t, -T

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day 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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.