Error using BCP

  • Hi all,

         I'm having a problem getting BCP to work correcty. I'm calling it from a stored procedure like so:

    EXEC master..xp_cmdshell @bcpCommand

    where @bcpCommand is set to:

    set @bcpCommand = 'bcp "SELECT * FROM (database name)..(table name)" queryout "C:\test\test.txt" -U (user name) -P (password) -c -t , -r \n'

    All items in parentheses have valid values, but for some reason I am getting the following error:

    SQLState = S1000, NativeError = 0

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

    I have SET NOCOUNT ON at the top of the procedure. Can anyone offer any further insight?

  • Why are you using -c AND -t , -r \n when the BOL documentation states -c uses \t and \n for the field and row??  I would also try putting the -U and -P in quotes



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • I had added the -t and -r in there while I was trying to get it to work. It still errors out without them. I also tried placing the username and the password in quotes, but that didn't solve anything either. The thing is, it works with one table I have, but not with the one I actually need it to work on.

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

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