[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2009-07-10
8
Medium Priority
?
1,846 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 43

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 43

Assisted Solution

by:pcelba
pcelba earned 600 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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 43

Assisted Solution

by:pcelba
pcelba earned 600 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 43

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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
What we learned in Webroot's webinar on multi-vector protection.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 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