How do I pass non-printable characters to BCP's field/row terminator parameters?
I have a tab delimited file I am trying to import into SQL Server 2012; the row terminator is CRLF. The following is my BCP statement in PowerShell:
bcp database.dbo.table IN C:\filePath.tsv -SserverName -UuserName -Ppassword -c -t\t -r\n
Which reports a
Unexpected EOF encountered
I can't for the life of me figure out why this is not working. An extra eye would be great.
EDIT: After review, I think the problem is with -r\n...What is the metacharacter for CRLF?
Encode it in hex:
bcp database.dbo.table IN C:\filePath.tsv -SserverName -UuserName -Ppassword -c -t0x9 -r0xa
You can use multiple characters by encoding each in hex and appending them together. For example, we use the record separator character, carriage return, and newline to separate each row, so we pass 0x1e0d0a as the value of the -r parameter.
I use ASCII Table to do quick lookups for this.