Friday, February 24, 2012

How to find Carriage Return CHAR(13)?

I've been looking for this online and on MSDN but no luck. I simply want to find all my CR in specific columns and later Replace them with a string (ie. --THIS-IS-A-CR--). The problem is I cannot even find/search CHAR(13) by using variations of the query below.

SELECT *
FROM Incident
WHERE (description LIKE '%CHAR(13)%') --I know this is incorrect

try this

SELECT *

FROM Incident

WHERE (description LIKE '%'+char(13)+'%')

|||Thanks Gopi, hope this post helps others as well|||

Gopi,

how will I replace with a string?

|||

This is what I am trying, it says that all rows have been updated, but when I do a find for the string I cannot find any changes to the table.

update Incident set
description = replace(cast(description AS varchar(8000)), '%'+char(13)+'%', '--THIS-WAS-CR--')
where description like '%'+char(13)+'%'

|||

try this

update Incident set

description = replace(cast(description AS varchar(8000)), char(13), '--THIS-WAS-CR--')

No comments:

Post a Comment