Monday, March 19, 2012

line feeds

Im parming a Nvarchar(4000) into a stored proc that uses xp_sendmail . is
there any way i can include any sort of line feed or cr in the varchar
currently if i parm in 'line 1 line 2' i get
line 1 line 2
but what i want to get is
line 1
line 2Hi Peter,
You can use SQL Server's CHAR function to insert LF or CR (CHAR(10) or
CHAR(13)) into the text to display it correctly:
-- Set QA to "Results in text" (<ctrl> + T)
SELECT 'line1' + CHAR(10) + 'line2'
HTH
Ami
"Peter Newman" <PeterNewman@.discussions.microsoft.com> wrote in message
news:B63EB308-13E7-411F-BE68-6EF58CDD0816@.microsoft.com...
> Im parming a Nvarchar(4000) into a stored proc that uses xp_sendmail .
is
> there any way i can include any sort of line feed or cr in the varchar
> currently if i parm in 'line 1 line 2' i get
> line 1 line 2
> but what i want to get is
> line 1
> line 2|||To add to Ami's response, you can include both carriage return and line feed
as your line terminator. This is the Windows convention.
SELECT 'line1' + CHAR(13) + CHAR(10) + 'line2'
Hope this helps.
Dan Guzman
SQL Server MVP
"Ami Levin" <XXX_NOSPAM___XXX__amlevin@.mercury.com> wrote in message
news:%23y4VSqFCFHA.2568@.TK2MSFTNGP10.phx.gbl...
> Hi Peter,
> You can use SQL Server's CHAR function to insert LF or CR (CHAR(10) or
> CHAR(13)) into the text to display it correctly:
> -- Set QA to "Results in text" (<ctrl> + T)
> SELECT 'line1' + CHAR(10) + 'line2'
> HTH
> Ami
> "Peter Newman" <PeterNewman@.discussions.microsoft.com> wrote in message
> news:B63EB308-13E7-411F-BE68-6EF58CDD0816@.microsoft.com...
> is
>

No comments:

Post a Comment