You are here: Replacing the second carriage return « MsSQL Server « IT news, forums, messages
Replacing the second carriage return

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация