1

I want to use new line in my select query

For example:

SELECT
    FULLNAME + ADDRESS AS X1
FROM 
    TBL_USERS

and the result should be something like this:

ABBAS KOLAHDOOZAN
ISFAHAN,BOZORGMEHR ST

as a single column.

I use CHAR(10), CHAR(13) but that dont work.

Does anyone have a working solution?

2 Answers2

5

The Sql

SELECT
 FULLNAME + CHAR(13) + CHAR(10) + ADDRESS AS X1
FROM
TBL_USERS;

Will insert a Windows CRLF between the columns. What you might be seeing is SSMS's Output to Grid results, which will eat whitespace. Switch to Text results mode if you want to see the actual result.

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285
0
DECLARE @name VARCHAR(MAX)= 'ABBAS KOLAHDOOZAN'
DECLARE @town VARCHAR(MAX)= 'ISFAHAN,BOZORGMEHR ST'
DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)

PRINT( @name + @NewLineChar + @town)
Dinesh Reddy Alla
  • 1,677
  • 9
  • 23
  • 47