Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 BCP Command - Login fails

Author  Topic 

GGoo
Starting Member

5 Posts

Posted - 2007-06-11 : 12:56:32
Dear all,

I have a curious problem using BCP to import and export data. First of all I export data as XML file with the command:

bcp "SELECT * FROM [006]..hopibon FOR XML EXPLICIT" queryout c:\ortec\misc\data.xml -c -r "" -SMMOSSURPBM09 –T

Now this works fine. The table data is exported as data.xml. I use the exported data in an external tool and then the result of that is a csv file. This file needs to be imported again in the SQL database, so I can run some queries. I use the following commandline;

bcp "[606]..ORTECPlanning" IN c:\ortec\misc\planning.csv -c -F1 -t; -SMMOSSURPBM09 –T

When I use this command I get the following error;

SQLState = 37000, NativeError = 4060
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database requested in login ‘[606]’. Login fails.

I tested the following:

1) Run the same command on local PC (SQL Installed) and then no problem at all. So the command seems to be correct.
2) Then I tried to use the –U –P parameters instead of –T. Then the error message changes and states login failed…
3) Changed the command to bcp "[606]..ORTECPlanning" IN "c:\ortec\misc\planning.csv" -c -F1 -t; -S"MMOSSURPBM09" –T
4) Changed the command to bcp [MMOSSURPBM09].[606]..ORTECPlanning IN c:\ortec\misc\planning.csv -c -F1 -t; -SMMOSSURPBM09 –T

But no luck… I’m using the administrator to login and perform the command. Exactly the same user and situation as in the queryout command…. So then the question is what is wrong with the command;

bcp [606]..ORTECPlanning IN c:\ortec\misc\planning.csv -c -F1 -t; -SMMOSSURPBM09 –T

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-11 : 13:08:03
Why do you have a semi colon in your code?
Try if this works:
 bcp "[606].dbo.ORTECPlanning" IN "c:\ortec\misc\planning.csv" -c -F1 -SMMOSSURPBM09 –T 




Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

GGoo
Starting Member

5 Posts

Posted - 2007-06-11 : 13:26:02
Tried the command without the semicolon (csv seperator) and the following results;

On the server -
Same error message - login failed

On my local machine -
I get a error

SQLState = S1000, Native error = 0
Error = [Microsoft][ODBC SQL Server Driver]Unexpected EOF encountered in BCP data-file

So removing the ; is not helping on the server and causing an error on the local machine...
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-11 : 13:34:27
Is the name of the server correct? Is MMOSSURPBM09 your local server?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

GGoo
Starting Member

5 Posts

Posted - 2007-06-11 : 13:42:07
The server name is correct. For my local server I change the servername in the command (same database). But as you also see the servername in the queryout command is working fine and is equal....

Gart
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-11 : 13:51:34
Why is this [606].dbo.ORTECPlanning in double quotes?

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

GGoo
Starting Member

5 Posts

Posted - 2007-06-11 : 14:02:10
Well I read in a post with the same problem that this was causing the error. But for me it doesn't change a thing. On the server I get the same error with or without quotes and on my local machine it works in both ways.

Gart
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-11 : 14:05:00
Try this:

bcp [606].dbo.ORTECPlanning IN c:\ortec\misc\planning.csv -c -F1 -t; -SMMOSSURPBM09 –T

What account are you logged into for Windows? Does that account have the necessary permissions on the server? -T says to use windows authentication to connect, so it uses the current credentials of the session that is running bcp.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

GGoo
Starting Member

5 Posts

Posted - 2007-06-11 : 14:12:42
Tried the command as suggested and I still get the same error message.

I'm working as administrator (network) an basically have all rights. Also I can run the command queryout without any problem on the same server, same database...

I double checked and added the administrator specifically (not as buildin only) with all rights (from sa to bulk insert) and also on database specific level all rights. Still the same login error...

Gart
Go to Top of Page
   

- Advertisement -