Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I use replace function to replace a carriage return

Status
Not open for further replies.

McCue

Programmer
May 21, 2001
2
US
Is it possible to use the replace function to replace a new line character or a carriage return within a string (like <br> for an html output)? I tried to use the ascii reference, but could not find the correct syntax to refer to an ascii character.

A db2 programmer suggested:
select replace(contact_telephone, X'10', '<br>') from bid_list

but this does not work in MS SQL Server. I would like to stick with ansi sql if there is a solution.

Any help is appreciated.

Gia McCue
 
Use the following in MS SQL Server to replace a line feed.

select
replace(contact_telephone, char(10), '<br>')
from bid_list

You may also want to replace char(13) - carriage return. You can do both in one statement.

--Replace CRLF with <br>
select
replace(contact_telephone, char(13)+char(10), '<br>')
from bid_list

--Replace CR and LF with <br> using nested replace
select
replace(replace(contact_telephone, char(10), '<br>'), char(13), '<br>')
from bid_list Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top