all groups > sql server (alternate) > september 2006 >
You're in the

sql server (alternate)

group:

Line Break in T-SQL



Line Break in T-SQL nashak NO[at]SPAM hotmail.com
9/14/2006 7:05:04 PM
sql server (alternate): 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,
Re: Line Break in T-SQL Alexander Kuznetsov
9/14/2006 7:09:38 PM
SELECT 'asdfasd'+char(13)+'ASDF ASF ASDF ASD'

maybe it's CHR not CHAR
Re: Line Break in T-SQL Dan Guzman
9/15/2006 12:00:00 AM
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

[quoted text, click to view]

Re: Line Break in T-SQL Hugo Kornelis
9/17/2006 9:58:48 PM
[quoted text, click to view]

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 ....

--
AddThis Social Bookmark Button