I have a table with name and an id
. And for this specified ids its like this
name id
--------------
BOB 19
Test 20
test2 21
but I want to change in code so its like this
name id
------------
BOB 1
Test 2
test2 3
Anyone got any suggestions? I want to change identity columns.
When I do this
set identity_insert Peapole OFF
GO
with CTE as
(
select
*, row_number () over (order by id) as RN
from Peapole
)
update CTE
set id = RN
I get an error:
Cannot update identity column 'id'.