SQL Server Performance

how to quary to fiend the last word

Discussion in 'SQL Server 2005 General Developer Questions' started by mpolaiah, Apr 1, 2009.

  1. mpolaiah New Member

    Hi friends,
    how to fiend the last word .example like my table
    ID ADDRESS
    1 1_94 SO MATTA REDDY RAJIV CHOWK SAGAR ROAD MIRYALAGUDA
    2 1_187 KERALA ROAD CHILUKUR
    3 Y KRISHNA REDDY ADVOCATE
    4 ADVOCATE VIJAY GARDEN BACKSID
    5 CH CHANDRAIAH ADVOCATE 6_2_15A
    6 NEAR 6_7_49 RAVINDRA NAGAR NALGONDA
    here i want last word of ADDRESS for example.....
    ID ADDRESS1
    1 MIRYALAGUDA
    2 CHILUKUR
    3 ADVOCATE
    4 BACKSID
    how to write the quary plz help me

  2. Madhivanan Moderator

    select
    Id,right(address,charindex(' ',reverse(address))-1) from your_table
  3. FrankKalis Moderator

    Just out of curiosity...
    What should be returned for ID 5?
  4. satya Moderator

    Is it a classroom based Q? [:)].
  5. rohit2900 Member

    Satya... I think u r right....[:D]

Share This Page