363,924 Members | 2595 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

Line Break in T-SQL

nashak@hotmail.com
P: n/a
nashak@hotmail.com
Hello,

In a Stored Proc, I am building a string variable. I am getting outputs
from 4 different queries and would like the string to have line breaks
to display each entry in a different line in a text area. How can I do
this?

i.e
result = result1 + result2 + result3 + result4.
What characters can I enter so that the output is displayed in the
textarea as
result1
result2
result3
result4

Thanks,

Sep 15 '06 #1
Share this Question
Share on Google+
3 Replies


Alexander Kuznetsov
P: n/a
Alexander Kuznetsov
SELECT 'asdfasd'+char(13)+'ASDF ASF ASDF ASD'

maybe it's CHR not CHAR

Sep 15 '06 #2

Dan Guzman
P: n/a
Dan Guzman
The line terminator on a Windows platform is carriage return/line feed
(ASCII 10 and 13). You can concatenate CHAR(13) + CHAR(10) where you want
line breaks.

--
Hope this helps.

Dan Guzman
SQL Server MVP

<nashak@hotmail.comwrote in message
news:1158285904.128023.10670@e3g2000cwe.googlegrou ps.com...
Hello,
>
In a Stored Proc, I am building a string variable. I am getting outputs
from 4 different queries and would like the string to have line breaks
to display each entry in a different line in a text area. How can I do
this?
>
i.e
result = result1 + result2 + result3 + result4.
What characters can I enter so that the output is displayed in the
textarea as
result1
result2
result3
result4
>
Thanks,
>

Sep 15 '06 #3

Hugo Kornelis
P: n/a
Hugo Kornelis
On 14 Sep 2006 19:05:04 -0700, nashak@hotmail.com wrote:
>Hello,
>
>In a Stored Proc, I am building a string variable. I am getting outputs
>from 4 different queries and would like the string to have line breaks
>to display each entry in a different line in a text area. How can I do
>this?
Hi Nashak,

In addition to the answers already given by Alexander and Dan, here's
another option - just use a newline character inside a string constant.

For example:

SELECT 'First line
Second line.'

This will show the output on two lines (make sure to select output to
text, not output to grid - the grid doesn't handle newlines too well).

If the data comes from columns, try

SELECT Column1 + '
' + Column2
FROM YourTable
WHERE ....

--
Hugo Kornelis, SQL Server MVP
Sep 17 '06 #4

Post your reply

Help answer this question



Didn't find the answer to your Microsoft SQL Server question?

You can also browse similar questions: Microsoft SQL Server tsql chr tsql+chr