Writing data to text file using BCP prompts for file storage type

后端 未结 2 1313
离开以前
离开以前 2021-01-24 03:22

I\'m copying data from SQL to text file using bcp tool with following command:

    bcp.exe \"exec \" queryout \"temp.txt\" -T -r\\n -c


        
相关标签:
2条回答
  • 2021-01-24 03:45

    There is no need to specify the record delimiter, so remove the -r\n. The -c option will use tab for columns and carriage return and line feed for records (same as specifying -t\t -r\r\n). Otherwise like the other poster stated, make sure the -c is specified first

    Side note: I recommend that as a practice (not as a solution) that you output the format file using -f"yourpathandfilename.fmt". On the client side you use the -f param with import as well. This way if there is a difference between the source and target you can manually tweak the format file.

    0 讨论(0)
  • 2021-01-24 04:00

    I would guess the somewhere between your test environment and the client's environment's actual execution of the command that the "/n" is getting turned into a real new-line. Try putting the "-c" before the "-r" and see what happens.

    0 讨论(0)
提交回复
热议问题