bcp error: Unable to open BCP host data-file

  • 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

  • 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.

  • 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

  • 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!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply