SQL Server Performance

Parse this string....

Discussion in 'SQL Server 2005 General Developer Questions' started by sql_jr, Jun 8, 2007.

  1. sql_jr New Member

    TEXT:9:GETTHISONLY:0

    Ok, so we see the delimiters ':', and I need to extract the value between the second ':' and the last ':', to return 'GETTHISONLY'. It will need to be so I can use it on any length string, but the pattern will always be the same. Please provide way to do this via tsql.......TIA!
  2. ndinakar Member

    looks like homework question.
    check out CHARINDEX function in books online. If you are still not able to get the query working post the query you have and we can guide you.

    ***********************
    Dinakar Nethi
    SQL Server MVP
    ***********************
    http://weblogs.sqlteam.com/dinakar/
  3. FrankKalis Moderator

  4. sql_jr New Member

    WOW, Frank! That's incredibly simple! - And it works for 2000 too!<br /><br />I see the PARSENAME function only parse where the delimiter is '.', so I totally understand.<br /><br />Genius! You can't believe the substrings and multi-line functions I came up with <img src='/community/emoticons/emotion-4.gif' alt=':p' /><br /><br />Thanks, again!
  5. FrankKalis Moderator

    Glad it works for you. Usually this string search and compare questions turn out much more complicated than initially thought.[<img src='/community/emoticons/emotion-1.gif' alt=':)' />]<br /><br />--<br />Frank Kalis<br />Microsoft SQL Server MVP<br />Contributing Editor, Writer & Forum Moderator<a target="_blank" href=http://www.sql-server-performance.com>http://www.sql-server-performance.com</a><br />Webmaster:<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a>
  6. Madhivanan Moderator

    Note that if the string has more than four : , then you need to modify the code accordingly
    Also, if you want to show the data in front end, it is very easy to use Split function there

    Madhivanan

    Failing to plan is Planning to fail

Share This Page