You are here: Re: String manipulation challenge in SQL « MsSQL Server « IT news, forums, messages
Re: String manipulation challenge in SQL

Posted by Steve Kass on 10/19/98 11:30

Here's another solution, which should work if you are certain that
the period character . is not part of any of the segments:

SELECT
CASE WHEN value NOT LIKE '%-%-%'
THEN ''
ELSE PARSENAME(REPLACE(value,'-','.'),2) END
FROM @t

Steve Kass
Drew University

wheresjim wrote:
> I have a sql query in which I need to isolate part of the columm value
> and return only that isolated portion. I can only do this within the
> select statement, and cannot add a function or anything like that. I
> would also like to keep this query within sql (I don't want to do this
> in my programming environment)
>
> The string value would normally look like "segment1-segment2-segment3".
> I need to isolate segment2, but I have to be able to account for
> situations in which either one or both dashes are missing (in which
> case returning "" or the whole string is OK. The best I have been able
> to do reliably is to get "segment2-segment3".
>
> Anybody want to take a stab?
>

 

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

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