SQL Server bcp command special symbol escape

Source: Internet
Author: User
Use the BCP command of sqlserver to import data two days ago. The column separator is [!]. The row delimiter is [end]. Because the two characters have special meanings and need to be escaped, after querying the data, it is found that the prefix of the BCP escape is not easy to use, which is ^ .. The detailed command is as follows: BCP [database]. dbo. [table] inC: dataimp3table.txt. out-t ^ [!] ^-R ^ [end] ^-

Use the BCP command of sqlserver to import data two days ago. The column separator is [!]. The row delimiter is [end]. Because the two characters have special meanings and need to be escaped, after querying the data, it is found that the prefix of the BCP escape is not easy to use, which is ^ .. The detailed command is as follows: BCP [database]. dbo. [table] in C: \ dataimp3 \ table.txt. out-t ^ [!] ^-R ^ [end] ^-

Use the BCP command of sqlserver to import data two days ago. The column separator is <[!]> The row delimiter is <[end]>. Because the <> two characters have special meanings and need to be escaped, after querying the data, it is found that the prefix of the BCP escape is very difficult. It is ^ .. The detailed commands are as follows:

BCP [database]. dbo. [table] in C: \ dataimp3 \ table.txt. out-t ^ <[!] ^>-R ^ <[end] ^>-c-B 15000-S 192.168.49.121-U sa-P password

Another solution is to add double quotation marks to all fields with special characters.

BCP [database]. dbo. [table] in "C: \ dataimp3 \ table.txt. out"-t "<[!]> "-R" <[end]> "-c-B 15000-S 192.168.49.121-U sa-P password


You can use 0x0A to indicate linux newline \ n.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.