Newline Characters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

To anyone who can help,

I'm trying to create a character string that will display output on two
different lines when an email notification goes out. The email part works,
however, the output isn't what I'm looking for. Here's the segment of code:


INSERT INTO @table (address_id,address,email)
SELECT i.address_id,'Customer Name: ' + n.Cust_Name + '||CHR(10)||Address:
' + n.house_number + ' ' +
CASE WHEN n.unit IS NULL THEN ''
WHEN n.unit IS NOT NULL THEN n.unit + ' ' END
+ n.street + ', ' + n.city,n.email
FROM #i i INNER JOIN tbladdress_notification n
ON i.address_id = n.address_id
ORDER BY i.address_id


I've also tried '\n' and '||chr(13)||' and both have been to no evail. The
output I'm looking for is:

Customer Name: (Name)
Address: (Address)

Any suggestions? THANKS!
 
Is this for a HTML formated email? If yes, then use «   » (without
the quote).

For T-SQL, CHR() is not a function, use CHAR() instead:

SELECT i.address_id,'Customer Name: ' + n.Cust_Name + Char(13) + Char(10) +
'Address: ' + ...


Even better:

declare @newline char(2)
set @newline = Char(13) + Char(10)


SELECT i.address_id,'Customer Name: ' + n.Cust_Name + @newline + 'Address: '
+ ...
 
That was it! Thanks!
--
Thanks in advance, D


Sylvain Lafontaine said:
Is this for a HTML formated email? If yes, then use « » (without
the quote).

For T-SQL, CHR() is not a function, use CHAR() instead:

SELECT i.address_id,'Customer Name: ' + n.Cust_Name + Char(13) + Char(10) +
'Address: ' + ...


Even better:

declare @newline char(2)
set @newline = Char(13) + Char(10)


SELECT i.address_id,'Customer Name: ' + n.Cust_Name + @newline + 'Address: '
+ ...
 
Back
Top