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
5) Remove –t; (suggestion) but this is causing the same error on the server and causing a new error unexpected EOF on the local machine
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
bcp "SELECT * FROM [006]..hopibon FOR XML EXPLICIT" queryout c:\ortec\misc\data.xml -c -r "" -SMMOSSURPBM09 –T
Now this works fine
I notice that the commands that fail seem to be hitting a different server ([606]) -NOT [006].
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.
Did I mis-read that?
没有评论:
发表评论