Thanks Ray - Len Word

  • This is I need, thanks Ray.

    One more question please, how update single characters in begin of string ?

    Ex: "M Carlos"

    Result:

    "Mh Carlos"

    Thanks a lot

    -- This update will get single characters in middle of string

    update mytable

    set myColumn = Stuff(@String, Patindex('% [A-Z] %', @String ) +2, 1, 'h ')

    where Patindex('% [A-Z] %', myColumn ) > 0

    -- This update will get single characters at the end of string

    update mytable

    set myColumn = myColumn + 'H'

    where Patindex('% [A-Z]', myColumn ) > 0

  • Example

    declare @String varchar(100)

    set @String = 'M Carlos'

    select Stuff(@String, Patindex('[A-Z] %', @String ) +1, 1, 'h ')

    Result

    'Mh Carlos'

    OOPS EDITED:

    update mytable

    set myColumn = Stuff(@String, Patindex('[A-Z] %', myColumn) +1, 1, 'h ')

    where Patindex('[A-Z] %', myColumn) > 0

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

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