问题
I have two string in sql server 2008 r2 query. I want to make new line between these strings like and I tried to do all with char() like below, but I'm still not success.
Could you show me any thing else. thanks!!!!!!!
declare @text1 varchar(20) = 'First';
declare @text2 varchar(20) = 'Last';
declare @string1 varchar(40)= @text1 + char(10) + @text2
select @string1;
declare @string2 varchar(40)= @text1 + char(13) + @text2
select @string2;
declare @string3 varchar(40)= @text1 + char(10) + char(13) + @text2
select @string3;
declare @string4 varchar(40)= @text1 + char(12) + @text2
select @string4;
回答1:
declare @string5 varchar(40)= @text1 + char(13) + char(10) + @text2;
select @string5;
Or, alternatively:
declare @string6 varchar(40)= @text1 + '
' + @text2;
select @string6;
回答2:
For this you can use ASCII character of carriage return char(39) (I forgot the exact no.) if you want it as a html <br> or \n while concatenating the string.
来源:https://stackoverflow.com/questions/26088715/new-line-in-sql-server-2008-r2