New line in Sql Query

Sql

Sql Problem Overview


How you get new line or line feed in Sql Query ?

Sql Solutions


Solution 1 - Sql

Pinal Dave explains this well in his blog.

http://blog.sqlauthority.com/2009/07/01/sql-server-difference-between-line-feed-n-and-carriage-return-r-t-sql-new-line-char/

DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)
PRINT ('SELECT FirstLine AS FL ' + @NewLineChar + 'SELECT SecondLine AS SL')

Solution 2 - Sql

-- Access: 
SELECT CHR(13) & CHR(10) 
     
-- SQL Server: 
SELECT CHAR(13) + CHAR(10)

Solution 3 - Sql

You could do Char(13) and Char(10). Cr and Lf.

Char() works in SQL Server, I don't know about other databases.

Solution 4 - Sql

use CHAR(10) for New Line in SQL
char(9) for Tab
and Char(13) for Carriage Return

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKuldipMCAView Question on Stackoverflow
Solution 1 - SqlSantosh ChandavaramView Answer on Stackoverflow
Solution 2 - SqlEric FalskenView Answer on Stackoverflow
Solution 3 - SqljvanderhView Answer on Stackoverflow
Solution 4 - SqlVinit PrajapatiView Answer on Stackoverflow