如何从 SQL Server 中的变量中删除所有 NewLine? [英] How I can remove all NewLine from a variable in SQL Server?
本文介绍了如何从 SQL Server 中的变量中删除所有 NewLine?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从 SQL Server 中的变量中删除所有 NewLine?
How can I can remove all NewLine from a variable in SQL Server?
我使用 SQL Server 2008 R2.
I use SQL Server 2008 R2.
我需要删除 T-Sql 命令中变量中的所有 NewLine.
I need remove all NewLine in a variable in a T-Sql Command.
例如:
Declare @A NVarChar(500)
Set @A = ' 12345
25487
154814 '
Print @A
它打印成这样:
12345
25487
154814
但我想得到这样的字符串:
But I want to get strings like this:
12345 25487 154814
12345 25487 154814
我写了这个查询,但它不起作用:
I write this query, but it does not work:
Set @A = Replace(@A,CHAR(13),' ')
推荐答案
您必须使用此查询
Declare @A NVarChar(500);
Set @A = N' 12345
25487
154814 ';
Set @A = Replace(@A,CHAR(13)+CHAR(10),' ');
Print @A;
这篇关于如何从 SQL Server 中的变量中删除所有 NewLine?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文