sql query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sridhar21
    New Member
    • Feb 2007
    • 26

    sql query

    hi to all

    i am sridhar

    i have 1 doubt

    Query to select the text after a particular character


    for example

    Sridhar's

    i want to select the text after ' (single quote)

    the result is 's'

    i need query for this


    thanks
  • chandu031
    Recognized Expert New Member
    • Mar 2007
    • 77

    #2
    Originally posted by sridhar21
    hi to all

    i am sridhar

    i have 1 doubt

    Query to select the text after a particular character


    for example

    Sridhar's

    i want to select the text after ' (single quote)

    the result is 's'

    i need query for this


    thanks
    Hi,

    This is the query:
    [code=sql]

    SELECT SUBSTRING('SRID HAR''S',CHARIND EX('`','SRIDHAR `S',1)+1,LEN('S RIDHAR''S'))

    [/code]

    However this will not work if you are looking for the second or higher instances of the search character(apost ophe in your case).

    Cheers!

    Comment

    • vijaii
      New Member
      • May 2007
      • 15

      #3
      SELECT right(Descripti on,len(Descript ion) - charindex(char( 39), Description))

      Here Description is the name such as "sridhar's"
      char(39) = " ' "

      However this will not work if you are looking for the second " ' "

      Comment

      Working...