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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2053793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:59:22  来源:igfitidea点击:

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

mysqlsql-serverinsert

提问by sipwiz

I'm attempting to insert some data from MySQL to SQL Server. I've dumped the MySQL table to a text file as SQL insert statements. I can insert it into SQL Server ok but the carriage returns are inserting as \r\n rather than as control sequences. 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 插入到 SQL Server。我已将 MySQL 表作为 SQL 插入语句转储到文本文件中。我可以将它插入到 SQL Server 中,但是回车是作为 \r\n 而不是作为控制序列插入的。如何替换 MySQL 插入语句中的 \r\n 字符串,以便它们最终在 SQL Server 中作为回车符?

回答by codekaizen

The only way I can think of is to replace \r\nwith ' + CHAR(13) + CHAR(10) + '.

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

回答by Guffa

Just replace the \r\n escape sequence with a line break. Example:

只需用换行符替换 \r\n 转义序列即可。例子:

select 'This is
a multi-line
string'