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)
 SQL Server 2000 - BCP

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-08 : 17:10:42
Sathya writes "Hi,

We need to execute a BCP command in SQL Server 2000 on Windows 2003 machine, which exports data to txt file "testbcp.txt" in the client machine which is on Windows XP.

The location of file in XP is "d:\bcptest\testbcp.txt" in Client machine. This folder is shared and when tried to open this folder from Server prompts for authentication, which when provided is able to access the folder.

The query i used is

XP_cmdshell 'BCP bankcal.dbo.siteconfig out "\\172.20.0.46\bcptest\test.txt" -U sa -P questionmark -S IBG-HKNG-VSQL -c -t\t -r\n '

172.20.0.46 - UNC name and shared path.
IBG-HKNG-VSQL is the server name (machine name of server).

This throws an error
Error = [Microsoft][ODBC SQL Server Driver]Unable to open BCP host data-file

Please let me know how to solve this issue.

Regards,
Sathya"

nosepicker
Constraint Violating Yak Guru

366 Posts

Posted - 2005-08-10 : 23:55:28
Is the client machine on a different domain? You may have to include the domain name in the UNC path (\\domainname\172.20.0.46\...). Or, you can use the "netuse" command to map a drive to the client machine and then BCP to that mapped drive. The "netuse" command will allow you to specify a login and password to connect to the shared drive.
Go to Top of Page

farhanrashid
Starting Member

2 Posts

Posted - 2006-12-04 : 00:52:47
HELP!!
I am running following command as a batch file on Windows XP with SQL Server 2000 and it works fine.

bcp "SELECT 'LKPLASTID', MAX(TABLEID) FROM MYDB..MYTABLE" queryout "D:\LOOKUPS\LASTID.csv" -T -c -t\, -e "D:\LOOKUPS\LASTID.log"

When I try to run the same batch file on Windows 2003 Server with SQL Server 2000, I get this error:

SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Unable to open BCP host data-file


I want to run this on standalone server machine not using any network connection in both cases (i.e XP & Windows Server 2003)

Can anyone please guide what could be the cause of this problem & how can i run the command successfully?

Thanks !

Go to Top of Page

farhanrashid
Starting Member

2 Posts

Posted - 2006-12-05 : 00:08:52
Can anyone help me to remove the error? I would appreciate also if someone can tell me an alternate method to export data using SQL query.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-12-05 : 00:14:20
Did you read nosepicker's post? If you're using local paths, then the files must exist on the server's local drives. You'll have to copy the files there. Otherwise, you have to use UNC paths. Avoid mapped network drives, they won't always be available for a SQL Server to use.
Go to Top of Page
   

- Advertisement -