Solved

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

Posted on 2009-07-10
8
1,734 Views
Last Modified: 2012-05-07
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.
0
Comment
Question by:APHComputersLtd
  • 4
  • 4
8 Comments
 
LVL 41

Expert Comment

by:pcelba
ID: 24825132
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.
0
 

Author Comment

by:APHComputersLtd
ID: 24838777
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
0
 
LVL 41

Assisted Solution

by:pcelba
pcelba earned 150 total points
ID: 24839185
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.
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:APHComputersLtd
ID: 24839617
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
0
 

Author Comment

by:APHComputersLtd
ID: 24839659
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.
0
 
LVL 41

Assisted Solution

by:pcelba
pcelba earned 150 total points
ID: 24846996
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.
0
 

Accepted Solution

by:
APHComputersLtd earned 0 total points
ID: 24847433
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
0
 
LVL 41

Expert Comment

by:pcelba
ID: 24847950
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!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sql Join Problem 2 43
Getting max record but maybe not use Group BY 2 27
Slow MySQL (InnoDB) Query with Inner Join & GroupBy 7 40
Mysql Left Join Case 10 48
Creating and Managing Databases with phpMyAdmin in cPanel.
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question