• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 411
  • Last Modified:

Add carriage return inside a varchar variable

I'm defining a varchar variable in a stored procedure and it would be easier to read if I could insert carriage returns into the variable.

Here's the variable

SET @BODY1 = @SEVERITY +  @SUBJ +  @FNAME + ' ' + @LNAME +
      ' ' + @COMPANY + ' ' + @PHONE + ' ' + @EMAIL +  @FB_DESC

@BODY1 is the @message parameter for xp_SENDMAIL so I don't know if there is another option for me.

Thanks,
0
SEANWYATT
Asked:
SEANWYATT
3 Solutions
 
rafranciscoCommented:
Try adding CHAR(13) like this:

SET @BODY1 = @SEVERITY + CHAR(13) + @SUBJ +  CHAR(13) + @FNAME + ' ' + @LNAME +
     ' ' + @COMPANY + ' ' + @PHONE + CHAR(13) +' ' + @EMAIL + CHAR(13) + @FB_DESC
0
 
Jan FranekCommented:
you can insert char(13) and char(10) into your string - on most clients it will create desired effect:

e.g.
SET @BODY1 = @SEVERITY +  char(13) + char(10) + @SUBJ +  char(13) + char(10) + @FNAME + ' ' + @LNAME +
     ' ' + @COMPANY + ' ' + @PHONE + ' ' + @EMAIL +  @FB_DESC
0
 
ispalenyCommented:
carriage returns is
CHAR(13)+CHAR(10)
0
 
SEANWYATTAuthor Commented:
Thanks all three!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now