Friday, March 29, 2019

Replace a newline in TSQL




I would like to replace (or remove) a newline character in a TSQL-string.
Any Ideas?



The obvious



REPLACE(@string, CHAR(13), '')


just won't do it...


Answer




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(10), '')

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...