I'm trying to terminate each row in BCP output with a specific string along with newline. Neither of these work:

  • -r"terminator_string\n"';
  • -r"terminator_string"+\n';

Any suggestions?

For an idea of the overall problem, see https://stackoverflow.com/questions/23329028/outofmemory-exception-when-reading-and-replacing-strings-with-streamreader-and-s

  • 2
    Could you provide more detail on what you want compared to what you are getting? Are the apostrophe and semi-colon part of the code? With -c -r "test\n" I'm getting what I think you're expecting. Apr 28 '14 at 3:13

Use the ASCII codes of the characters you want to match (without the 0x prefix).

For example to match A (char hex 41) + LineFeed (char hex 0A) do this:

-r "410A"

This seems to be undocumented. See my blog here for more info: http://kejser.org/databases/bulk-insert-with-linux-line-endings/


Check Specifying Field and Row Terminators for bcp


-r \n -Specifies the row terminator as a newline character. This is the default row terminator, so specifying it is optional.

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.