use common go drop table transform_work go CREATE TABLE dbo.transform_work ( spid int NULL , freq int null, sort_id int IDENTITY (1, 1) NOT NULL , type char(1) NOT NULL , tsql varchar (255) NULL ) GO CREATE UNIQUE CLUSTERED INDEX i1 ON dbo.transform_work(spid, sort_id) WITH FILLFACTOR = 80 GO create trigger TR1_transform_work on transform_work for insert as UPDATE transform_work SET spid=@@spid FROM inserted i , transform_work r WHERE i.sort_id=r.sort_id AND r.spid=null GO