Replace statement

  • I want to replace the first part of a string (41331111 to 55551111).

    Table name: 'ITEM' ,col:'CTLG_NO' ,

    look on bol. need a little more help

    THANKS

  • Is this what you want?

    update ITEM

    set CTLG_NO = replace(CTLG_NO,'55551111','41331111')

    test it first though


    Growing old is mandatory, growing up is optional

  • hi,

    shouldn't it be :-

    update ITEM

    set CTLG_NO = replace(CTLG_NO,'41331111','55551111')

    from 41331111 to 55551111 ?

    Paul

  • Yes it should, i forgot to switch the two values back round after a bit of testing. Thanks for pointing that out.


    Growing old is mandatory, growing up is optional

  • Thanks thats almost it but I need to keep the last four digits '1111. I looking to replace the first four digits only.

    41331111 55551111

    41331112 55551112

    41331113 55551113

    dont know if a like statment will do?

  • Hi,

    just use :-

    update ITEM

    set CTLG_NO = replace(CTLG_NO,'4133','5555')

    instead (see replace in BOL for an explanation)

    Paul

Viewing 6 posts - 1 through 5 (of 5 total)

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