I would like to replace (or remove) a newline character in a TSQL-string. Any Ideas?
(UPDATE) The obvious
REPLACE(@string,CHAR(13),'')
just won't do it...
I would like to replace (or remove) a newline character in a TSQL-string. Any Ideas?
(UPDATE) The obvious
REPLACE(@string,CHAR(13),'')
just won't do it...
The Newline in T-SQL is represented by CHAR(13) & CHAR(10) (Carriage return + Line Feed). Accordingly, you can create a REPLACE statement with the text you want to replace the newline with.
REPLACE(MyField, CHAR(13) + CHAR(10), 'something else')
Actually a new line in a SQL command or script string can be any of CR, LF or CR+LF. To get them all, you need something like this:
SELECT REPLACE(REPLACE(@str, CHAR(13), ''), CHAR(11), '')