SQL - Remove or replace carriage return in a column



If you have one column  in a SQL table and you  need to replace the carriage return with a blank or other character.

You can do this:
-- Last parameter is the applied instead carriage return

UPDATE TableName SET ColumnName = Replace (ColumnName , CHAR(10), '')

-- If need just one value not all the column add conditional to update script

UPDATE TableName
SET ColumnName = Replace (ColumnName , CHAR(10), ',')
WHERE ...(e.g. WHERE id = 12)

Latest
Previous
Next Post »