Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

bcp error: Unable to open BCP host data-file Expand / Collapse
Author
Message
Posted Thursday, December 18, 2008 12:25 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, October 29, 2013 2:40 PM
Points: 180, Visits: 242
I get this error message:

SQLState = HY000, NativeError = 0
Error = [Microsoft][SQL Native Client]Unable to open BCP host data-file

if I try to run

EXEC master..xp_cmdshell
bcp "select top 100 * from test.dbo.Table_1" queryout "c:\data.txt" -c -Usa -Psa123 -SD-D-MIRS\SQLEXPRESS'


from Query Analyzer (or a store procedure).


If run the same command in cmd or run window (without EXEC and xp_cmdshell) I do not get any error and the content of the table is exported in the file I want...

If the exported file is on a local folder on the server everything is working fine even in Query Analyzer...

Thank
Manas
Post #621818
Posted Sunday, January 31, 2010 1:26 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 1, 2012 7:08 AM
Points: 1, Visits: 22
Make sure cmdshell is enabled.

The best way is to create a job and make sure the Job is running under the correct user which has the rights to read/write to the folder.
Post #856857
Posted Thursday, March 10, 2011 6:55 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, March 10, 2011 6:49 AM
Points: 1, Visits: 5
Hi,

I had the same scenario.

Check the sql server service, it should be running with permissions for the folder that you're extracting to.

I'm using SQL express 2008 R2 with a Local system account.
It didn't work, because it was configured to use a Network Service.

Best regards,
Chen
Post #1076209
Posted Tuesday, August 7, 2012 4:50 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, August 29, 2014 7:14 AM
Points: 31, Visits: 207
I received a similar error message when running a bcp command from SSMS, however it ran ok from a command prompt.

The SQL Service Account didn't have write permissions to the output file location!
Post #1341147
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse