Add a column to existing table and uniquely number them on MS SQL Server

前端 未结 8 1253
暖寄归人
暖寄归人 2020-12-04 08:16

I want to add a column to an existing legacy database and write a procedure by which I can assign each record a different value. Something like ad

8条回答
  •  有刺的猬
    2020-12-04 08:50

    Depends on the database as each database has a different way to add sequence numbers. I would alter the table to add the column then write a db script in groovy/python/etc to read in the data and update the id with a sequence. Once the data has been set, I would add a sequence to the table that starts after the top number. Once the data has been set, set the primary keys correctly.

提交回复
热议问题