I have a table like this:
ID text_1 text_2 text_3
12 some text some more even more
I need it to be put it to be put to one string so it comes out like
some text\n\nsome more\n\neven more
Now I know that开发者_如何学Python \n is something else in TSQL but I can't remember what, maybe CHAR(13).
Anyone know to archive this?
This query will return the string you want:
SELECT text_1 + '\n\n' + text_2 + '\n\n' + text_3
FROM myTable
If you want a line break character you will indeed need to use CHAR(13) and for a line feed CHAR(10), in a similar manner:
SELECT text_1 + CHAR(13) + CHAR(10) + text_2 + CHAR(13) + CHAR(10) + text_3
FROM myTable
As @Adam Robinson comments, if the text_x fields are of type TEXT or NTEXT you will need to convert them first.
加载中,请稍侯......
精彩评论