extract text after a ',' (comma)

  • how do i extract text after a ',' comma for example i have address in this format:

    ZION , IL 60099

    and i want to extract the state and zipcode after ',' only

    Thanks

  • Use SUBSTRING in conjunction with a CHARINDEX function. CHARINDEX will allow you to find the starting point of your return string

    Something like:

    declare @fun varchar(75)

    set @fun='ZION , IL 60099'

    select substring(@fun,charindex(',',@fun)+1,len(@fun))

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 2 posts - 1 through 1 (of 1 total)

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