IF EXISTS (SELECT name FROM sysobjects
WHEREname = 'tri_max'
AND
type = 'TR')
DROP TRIGGER tri_maxGOCREATE TRIGGER tri_maxON mydb..t2FOR insert,updateAS if exists (select 1 from t2 a,inserted b where a.id<b.id)--if inserted.id<(select max(id) from t2) --group by id having max(id)<1)BEGIN