Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 2 of 2

Thread: copy one field to another then modify it

  1. #1
    jerm324 is offline Senior Member
    Join Date
    Oct 2009
    Posts
    122

    Default copy one field to another then modify it

    1. I'd like to copy the sku field in dbo.product into the manufacturer part number field.

    2. I'd like to remove all punctuation, especially dashes from the data in manufacturer part number field after the copy.

    So my goal would be ex. 620-400 in the sku field and 620400 in the mfg part# field.

    Are the command that can be used to do this? I have 14000 parts I need to do this for.

    Thanks

  2. #2
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    UPDATE [Product]
    SET [ManufacturerPartNumber] = [SKU]

    UPDATE [Product]
    SET [ManufacturerPartNumber] = REPLACE([ManufacturerPartNumber],'-','')

    or you could do it in one statement

    UPDATE [Product]
    SET [ManufacturerPartNumber] = REPLACE([SKU],'-','')

    and if you want to replace other punctutation you have to use more REPLACE statements, such as:

    UPDATE [Product]
    SET [ManufacturerPartNumber] = REPLACE(REPLACE([SKU],'-',''),',','')

    which would replace all of the dashes - and all of the commas , or

    UPDATE [Product]
    SET [ManufacturerPartNumber] = REPLACE(REPLACE(REPLACE([SKU],'-',''),',',''),'.','')

    which would replace all dashes commas and full-stops.

    You get the idea now.

    AS ALWAYS MAKE SURE YOU HAVE A BACKUP IN PLACE BEFORE YOU DO THIS SORT OF THING IF YOU DON'T KNOW WHAT YOU'RE DOING!