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 Answers 2
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
E.g.:
-r \n -Specifies the row terminator as a newline character. This is the default row terminator, so specifying it is optional.
Hope this helps
-c -r "test\n"
I'm getting what I think you're expecting.