create table t1 (col1 int, col2 varchar(10)) insert into t1 values (10, 'olddata')
- add col id
alter table t1 add col3 int identity(1,1) GO
- rename or delete the old column
alter table t1 drop column col1
- rename the new col to the name of the old col
exec sp_rename 't1.col3', 'col1', 'column' GO
- add a new test, view the table
insert into t1 values ( 'newdata')
select * from t1
TeamDataViz.
source share