if object_id('test')is not null drop table test go create table test([Name] varchar(10)) insert test select 'A' insert test select 'B' select * from test alter table test add id int identity(1,1) select * from test /* Name ---------- A BName id ---------- ----------- A 1 B 2 */
go
create table test([Name] varchar(10))
insert test select 'A'
insert test select 'B'
select * from test
alter table test
add id int identity(1,1)
select * from test
/*
Name
----------
A
BName id
---------- -----------
A 1
B 2
*/