两张表,a表4个字段,b表3个字段,根据a表的最后一个字段的值0或1,来对b表插入或删除。
用触发器来写,怎么写啊~~
俺没分,不好意思啊~
create TRIGGER [dbo].[aInsert]
ON [dbo].[a]
for insert
AS
BEGIN
declare @d bit
select @d=d from inserted
if (@d=1)
insert
else
delete
end
create TRIGGER [dbo].[aInsert] declare @d bit select @d=d from inserted insert else delete end
ON [dbo].[a]
for insert,update
AS
BEGIN
if (@d=1)
create tigger tig_insert
on a for insert,update
as
begin
declare @b int--如果是bool的用bit
select @b = 字段4 from inserted
if(@b=1)
insert
else
delete
select @b = 字段4 from updated
if(@b=1)
insert
else
delete
end