Reputation: 29
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?
Upvotes: 1
Views: 1924
Reputation: 1717
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)
Upvotes: 0
Reputation: 107277
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.
Upvotes: 5