With table test
create table Test(ID int)
You can do it
exec sp_rename 'dbo.Test', 'tmp_Test', 'OBJECT'
go
create table dbo.Test(
ID int not null identity
)
go
set identity_insert dbo.Test on
go
insert into dbo.Test(ID) select ID from dbo.tmp_Test
go
set identity_insert dbo.Test off
go
drop table dbo.tmp_Test
go
source
share