string functions in sql

  • is there any function in sql server 2000 to find the position of a specified string

    like i want to  find "|" in this string--> 80339inesh|80339:dinesh badgujar|80339:dinesh badgujar

    it is 13th

    is there anything like that ??

    <a href="http://www.websolsoftware.com"> For IT jobs click here</a>

    *Sukhoi*[font="Arial Narrow"][/font]

  • Have you looked at CHARINDEX ?

    /Kenneth

  • it gives value 0, it always give value 0, it is deterministic function

    <a href="http://www.websolsoftware.com"> For IT jobs click here</a>

    *Sukhoi*[font="Arial Narrow"][/font]

  • Indeed...?

    select charindex('|', '80339:dinesh badgujar|80339:dinesh badgujar')

    -----------

    22

    (1 row(s) affected)

    Doesn't look too deterministic to me...

    /Kenneth

  • SELECT CHARINDEX('|', '80339inesh|80339:dinesh badgujar|80339:dinesh badgujar')

    SELECT PATINDEX('%|%', '80339inesh|80339:dinesh badgujar|80339:dinesh badgujar')



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • use it with the column name

    like

    select charindex(rmlist,'|',1)

    use it this way and see

    <a href="http://www.websolsoftware.com"> For IT jobs click here</a>

    *Sukhoi*[font="Arial Narrow"][/font]

  • HI, it will work with colum name as well, thing is you have the order of the variables backwards.

    the first string is what your looking for, the second is what your searching so for instance

     

    Select Eyecolor from Eyecolor

    Where ('bl',eyecolor)>0

     

    Yields 'Blue' and 'black'

     

    Hope that helps

     

    Tal McMahon


    Kindest Regards,

    Tal Mcmahon

  • Try to avoid regular expressions for obvious speed reasons, but when necessary or speed isnt an issue they are great.  Here is a link to a way to use them from TSQL

     

    http://www.codeproject.com/database/xp_pcre.asp

     

    - john

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply