Update SQL with consecutive numbering

前端 未结 10 586
庸人自扰
庸人自扰 2020-12-02 20:16

I want to update a table with consecutive numbering starting with 1. The update has a where clause so only results that meet the clause will be renumbered. Can I accomplish

10条回答
  •  既然无缘
    2020-12-02 20:48

    If you want to create a new PrimaryKey column, use just this:

    ALTER TABLE accounts ADD id INT IDENTITY(1,1) 
    

提交回复
热议问题