I have read many articles explaining what CHAR(10) and CHAR(13) actually are.
I have no problem with CHAR(10), it is simply a line feed or a new line.
I do not understand how CHAR(13) behaves in SQL Server.
See below simple code:
Case 1 - Simple new line
Case 2 - Again, a new line. But why?
Case 3 - 2 new lines. Assuming char(10) and char(13) are returning a new line each (Case 2).
Case 4 - Why 1 new line only?
PRINT '----------Case 1----------'
DECLARE @str1 nVarchar(MAX) = 'Hello' + CHAR(10) + 'World'
PRINT @str1
PRINT '----------Case 2----------'
DECLARE @str2 nVarchar(MAX) = 'Hello' + CHAR(13) + 'World'
PRINT @str2
PRINT '----------Case 3----------'
DECLARE @str3 nVarchar(MAX) = 'Hello' + CHAR(10) + CHAR(13) + 'World'
PRINT @str3
PRINT '----------Case 4----------'
DECLARE @str4 nVarchar(MAX) = 'Hello' + CHAR(13) + CHAR(10) + 'World'
PRINT @str4
PRINT '----------END----------'
vbCrLf. Always put the carriage return first. If you're just printing stuff in SSMS, though, you only need one or the other.