简体   繁体   English

插入SQL Server时用于\ r \ n的字符

[英]Characters to use for \r\n when inserting into SQL Server

I'm attempting to insert some data from MySQL to SQL Server. 我正在尝试将一些数据从MySQL插入SQL Server。 I've dumped the MySQL table to a text file as SQL insert statements. 我已经将MySQL表作为SQL插入语句转储到文本文件中。 I can insert it into SQL Server ok but the carriage returns are inserting as \\r\\n rather than as control sequences. 我可以将它插入到SQL Server中,但是回车符插入为\\ r \\ n而不是作为控制序列。 How can I replace the \\r\\n strings in the MySQL insert statements so that they will end up as carriage returns in SQL Server? 如何替换MySQL插入语句中的\\ r \\ n字符串,以便它们最终在SQL Server中作为回车符结束?

我能想到的唯一方法是用' + CHAR(13) + CHAR(10) + '替换\\r\\n

Just replace the \\r\\n escape sequence with a line break. 只需用换行符替换\\ r \\ n转义序列即可。 Example: 例:

select 'This is
a multi-line
string'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM