create trigger tr_process on yd
for insert,update
as
if exists(select 1 from bm a where not exists(select 1 from inserted where id=a.id))
rollback tran
创建存储过程
-------------
create proc prc_insert_ta
@iid varchar(50)
as
if(exists(select iid from tb where iid=@iid))
begin
insert ta values(@iid)
end
-------------
create trigger tr_yd
on yd
for insert,update
as
if exists (select 1 from inserted i where not exists ( select 1 from bm where id=i.id)
)
begin
ROLLBACK TRANSACTION
RAISERROR('违反规则',16,1)
return
end