Newline Characters

D

D

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!
 
S

Sylvain Lafontaine

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: '
+ ...
 
D

D

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: '
+ ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top