SQL - Add 1 to a figure

  • Hi all,

    I have a range of numbers in a table which start with 451.  I need to update this range to begin with 1451, but only for a selected range.  Can someone offer up a quick substring type update statement I can use?

    Many thanks,

    Paula.

  • Is that number represented as a varchar ?

    If yes then

    update set col = '1' + col

    where left(col,3) = '451'

    if not then cast it:

    update set col = cast('1' + cast(col as varchar(200) as int )

    where left(cast(col as varchar(200),3) = '451'

    without further details it would be harder to give a better answer


    * Noel

  • That's great, thanks.

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

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