471,050 Members | 1,137 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,050 software developers and data experts.

removing chr(13) and chr(10) from SQL


Is there a way to remove carriage returns and line feeds from a field in SQL.

Here is what I have at the moment:

CAST(m.Description AS VARCHAR(8000))AS "Product Description"

(have had to cast as VarChar because of problems with aggregate functions in rest of query).

Problem is that this m.description field has carriage returns and line breaks in it .. how do I remove these inside the SQL statement?

Dec 21 '06 #1
3 52864
168 Expert 100+
Have you tried REPLACE ( StringExpression1 , StringExpression2 , StringExpression3 ) T-SQL function?
Dec 22 '06 #2
I tried something like this:

CAST(replace(m.Description, vlbf, ' ') AS VARCHAR(8000))AS "Product Description",

and tried variations of vlbf such as chr(10) chr(13) or \r\n and none of them worked.

I can't put them in single quotes as SQL will look for the actual occurence in the string rather than what it stands for.

I get the error column vlbf is unknown or chr(10) is an unknown function....
Dec 22 '06 #3
sorted it now..... used this in the end:

REPLACE(CAST(m.Description AS varChar(1000)),char(13) + char(10),' ') AS "Product Description",

Thanks for the help
Dec 22 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by Eddie B. | last post: by
6 posts views Thread by C L Humphreys | last post: by
2 posts views Thread by lauren quantrell | last post: by
10 posts views Thread by Dan Nash | last post: by
1 post views Thread by Felix | last post: by
5 posts views Thread by Computer Guru | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.