I\'ve searched StackOverflow for all the possible solutions concerning how to insert a linebreak in a SQL text string. I\'ve referred this link but to no avail. How to inser
The CR/LF chars are there, it's just that in the format of your output, they are being ignored.
I've created a fiddle to illustrate this, with 2 VARCHAR
columns. In the first one I insert the text with no CR/LF
, in the second I include them
CREATE TABLE sample (dex INT, colnocr VARCHAR(50), col VARCHAR(50)) ;
insert into sample (dex, colnocr, col) values
(2,
'This is line 1.' + 'This is line 2.',
'This is line 1.' + CHAR(13) + CHAR(10) + 'This is line 2.'
)
;
if you run the query
SELECT * FROM sample
The result in plain text are:
| dex | colnocr | col |
|-----|--------------------------------|----------------------------------|
| 2 | This is line 1.This is line 2. | This is line 1.
This is line 2. |
but if you run it in tabular :
dex colnocr col
2 This is line 1.This is line 2. This is line 1. This is line 2.
Check it : SqlFiddleDemo