当插入到SQL服务器时,用于\r\n的字符

时间:2022-07-01 07:07:27

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 insert语句转储到一个文本文件中。我可以将它插入到SQL Server ok中,但是回车是作为\r\n而不是作为控制序列插入的。如何替换MySQL insert语句中的\r\n字符串,使它们在SQL Server中作为回车?

2 个解决方案

#1


12  

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

我唯一能想到的方法就是用“+ CHAR(13) + CHAR(10) +”来替代\r\n。

#2


0  

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

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

select 'This is
a multi-line
string'

#1


12  

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

我唯一能想到的方法就是用“+ CHAR(13) + CHAR(10) +”来替代\r\n。

#2


0  

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

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

select 'This is
a multi-line
string'