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
It works perfectly:
CREATE TABLE sample(dex INT, col VARCHAR(100));
INSERT INTO sample(dex, col)
VALUES (2, 'This is line 1.' + CHAR(13)+CHAR(10) + 'This is line 2.');
SELECT *
FROM sample;
LiveDemo
Output:
The "problem" is SSMS
grid view that skips newline characters (and others too). Otherwise you will get different rows height like in Excel
.
You could observe the same behaviour in SEDE
.
LiveDemo-SEDELiveDemo-SEDE-TextView
Output:
You could compare it using:
SELECT 'This is line 1.' + CHAR(13)+CHAR(10) + 'This is line 2.';
PRINT 'This is line 1.' + CHAR(13)+CHAR(10) + 'This is line 2.';