Coder Perfect

Sql Query has a new line.


In SQL Query, how do you get a new line or line feed?

Asked by KuldipMCA

Solution #1

Pinal In his blog, Dave discusses this in detail.

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')

Answered by Santosh Chandavaram

Solution #2

-- Access: 
SELECT CHR(13) & CHR(10) 

-- SQL Server: 

Answered by Eric Falsken

Solution #3

You can use Char(13) and Char(14) (10). Lf and Cr.

I know that Char() works in SQL Server, but I’m not sure about other databases.

Answered by jvanderh

Solution #4

In SQL, CHAR(10) is used for New Line, CHAR(9) is used for Tab, and CHAR(13) is used for Carriage Return.

Answered by Vinit Prajapati

Post is based on