SqlServer:传递超长字符串参数时,参数被自动换行。

declare @ids nvarchar(max);
set @ids=N'5936593066,5936556893,59366
00375,5936594808,59
36624757,5936625206'
declare @char char(2);
set @char=N'
'

--5936593066,5936556893,5936600375,5936594808,5936624757,5936625206
select replace(@ids,@char,'')

 如果上边的解决方案不可以,可以采用:

declare @char char(2);
declare @char2 varchar(1);
set @char=N'
';
set @char2=N'
 ';

declare @myIds nvarchar(max);
set @myIds=N'59366
00375'

print REPLACE(@myIds,@char,'');
    
    
declare @ids nvarchar(max);
set @ids=N'59366
00375';

print replace(replace(@ids,@char,''),@char2,'')

 

posted @ 2016-03-01 17:18  cctext  阅读(1056)  评论(0编辑  收藏  举报