Tech Sharing

Tech Sharing

Advertisement

Remove Carriage Return, Line Feed, Tab in TSQL

By on May 25, 2012

Having problem when I try to display the message that retrieved from database with the line break. When I try to manipulate the message using javascript, I keep getting the message of unterminated string javascript error message.

tech.david-cheong.com

Try to google for the alternative to remove the line break getting from DB, the following is the snippet of SQL code to remove carriage return/line feeds

tech.david-cheong.com

REPLACE(REPLACE(REPLACE(MyField, CHAR(10), ''), CHAR(13), ''), CHAR(9), '')
tech.david-cheong.com

If you wish to replace with the line break in javascript,  the following script will replace the line break with the n

tech.david-cheong.com

REPLACE(REPLACE(REPLACE(MyField, CHAR(10), ''), CHAR(13), 'n'), CHAR(9), '')
tech.david-cheong.com




 

Comments

No Responses to “Remove Carriage Return, Line Feed, Tab in TSQL”

Write a Comment

Captcha *

%d bloggers like this: