Search code examples
sqlnexusdb

How to add 10000 to existing column?


I have a table called stock and one of the column is called stock_code. The stock_code is all 5 digit int (I believe), but now I'm running out of numbers, I need to change all the code to 10 digit. So I need to add 10000 to all the stock_code. Can someone help me please?


Solution

  • If it's a number:

    UPDATE stock SET stock_code = 1000000000 + stock_code;
    

    or, to keep a better view on the number of zeros:

    UPDATE stock SET stock_code = (10000 * 10000) + stock_code;