if (object_id('tabTest') is not null) drop table tabTest
if (object_id('tabTest') is null)begin
create table tabTest(tid int identity(1,1) primary key,tn varchar(20))
end
go
select OBJECTPROPERTY(OBJECT_ID('tabTest','U'),'TableHasIdentity')
select columnproperty(object_id('tabTest','U'),'tid','IsIdentity')
alter table tabTest add tid1 int not null default(0)
update tabTest set tid1=tid
declare @cn varchar(200)
select @cn=isnull(name,'') from sysobjects where parent_obj=object_id('tabTest','U') and xtype='PK'
if(@cn<>'') exec('alter table tabTest drop constraint '+ @cn)
alter table tabTest drop column tid
EXEC sp_rename 'tabTest.[tid1]', 'tid', 'COLUMN'
alter table tabTest add primary key(tid);
select OBJECTPROPERTY(OBJECT_ID('tabTest','U'),'TableHasIdentity')
select columnproperty(object_id('tabTest','U'),'tid','IsIdentity')