if not exists(SELECT column_name from sys.syscolumn sc join sys.systable st on sc.table_id = st.table_id where LCase(table_name) = LCase('Objects') and LCase(column_name) = LCase('IsSource')) then alter table Objects add "IsSource" integer default 1; end if; go IF (EXISTS(Select * from sys.systrigger where LCase(trigger_name) = LCase('InsSvoObjectsStn'))) THEN Drop trigger InsSvoObjectsStn END IF GO create trigger InsSvoObjectsStn after insert order 1 on DBA.Objects referencing new as NewRow for each row /* WHEN( search_condition ) */ begin if NewRow.handle_id = 3 and NewRow.IsSource = 1 then insert into SvoObjectsStn( Glava,Svoistvo,Stoinost) values( NewRow.Id,'31','1') end if end go if not exists(SELECT column_name from sys.syscolumn sc join sys.systable st on sc.table_id = st.table_id where LCase(table_name) = LCase('Handles') and LCase(column_name) = LCase('CanBeDest')) then alter table Handles add "CanBeDest" integer default 0; end if; go update Handles set CanBeDest = 1 where id in(3,4,5)