|
Posted by asturt on 10/06/06 19:46
I have a string with multiple carriage returns in it. I need to remove
the second carriage return but leave all the rest. Anyone know of a
function that will do this?
I've come up with this:
/***********************************************/
DECLARE @MyString varchar(100)
SET @MyString='Line one.
Line two.
Line three.
Line four.'
SELECT @MyString
SELECT @MyString = LEFT(@MyString, CHARINDEX(CHAR(13), @MyString,
CHARINDEX(CHAR(13), @MyString, 0)+1)-1)
+ RIGHT(@MyString, LEN(@MyString)-(CHARINDEX(CHAR(13), @MyString,
CHARINDEX(CHAR(13), @MyString, 0)+1)+1))
SELECT @MyString
/***********************************************/
However, if there is a less convoluted way of doing this, I'd love to
know.
Navigation:
[Reply to this message]
|