DROP TRIGGER _TI_tbl-name
GO |
select ident_current('schemaname.tbl-name') as old_identity_value
go |
drop index table#_#progress_recid on table
drop index table#_#progress_recid_ident_on table |
drop index table#_#index on table
|
EXEC sp_rename 'tbl-name.PROGRESS_RECID', 'PROGRESS_RECID_BKP' ,'COLUMN'
|
alter table tbl-name drop column PROGRESS_RECID_IDENT_
|
ALTER TABLE tbl-name
ADD PROGRESS_RECID AS CASE WHEN PROGRESS_RECID_ALT_ is null THEN PROGRESS_RECID_IDENT_ ELSE PROGRESS_RECID_ALT_ END PERSISTED not null, PROGRESS_RECID_IDENT_ bigint identity, PROGRESS_RECID_ALT_ bigint null default NULL, CONSTRAINT tbl-name#_#progress_recid UNIQUE(PROGRESS_RECID) GO |
update tbl-name set PROGRESS_RECID_ALT_ = PROGRESS_RECID_BKP
go |
DBCC CHECKIDENT ('tbl-name', RESEED, <old-identity-value>)
go |
alter table tbl-name drop column PROGRESS_RECID_BKP
go |
create index table#_#index on table (column, PROGRESS_RECID)
go |