query delete some part of string

  • Might be a slightly cleaner way, but this works:

    select case charindex('.', Column1)

    when 0 then Column1

    else stuff(Column1, charindex('.', Column1), charindex('\', Column1, 3) - charindex('.', Column1) - 1, '') end

    from @t_temp;

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • SELECT ISNULL(STUFF(@str, CHARINDEX('.', @STR), CHARINDEX('\', @STR, 3) - CHARINDEX('.', @STR) - 1, ''), @STR);

    -- Cory

  • Of course ^

    ISNULL is better than doing a CASE.

    └> bt



    Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • bteraberry (5/7/2010)


    Of course ^

    ISNULL is better than doing a CASE.

    Oh good, I was able to save face for that substring inefficient code. 😀

    -- Cory

Viewing 4 posts - 16 through 18 (of 18 total)

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