create trigger trigger_del on tb_vn
after delete
as
begin
declare @vname varchar
select @vname=vname from deleted
delete from tb_dj where jsv=@vname
end
------解决方案--------------------
这个还是有一点问题的,如果一次性删除的是多条记录,那么DELETED应该会有多条记录,而在Trigger中之定义一个@vname参数就会导致少删除数据。所以应该用deleted join tb_dj 然后删除记录 。 ------解决方案-------------------- create trigger trigger_del on tb_vn
after delete
as
begin
select vname into #temp11 from deleted
delete from tb_dj where jsv in (select vname from #temp11)
drop table #temp11
end ------解决方案--------------------
create trigger trigger_del on tb_vn
after delete
as
begin
select vname into #temp11 from deleted
delete from tb_dj where EXISTS (select vname from #temp11)
drop table #temp11
end