SQL Server: Replace Carriage Return and / or Line Feed characters

Use the following to replace all Carriage Return and Line Feed characters with spaces

replace(replace(string, char(10), char(32)), char(13), char(32))

10 = Line Feed
13 = Carriage Return
32 = space

Normally you will want to trim the resulting string too:

rtrim(ltrim(string))
Advertisements

One response to “SQL Server: Replace Carriage Return and / or Line Feed characters

  1. It’s all double dutch to me?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s