create trigger t_info on A instead of insert as declare @amount int set @amount=(select amount from inserted) if(@amount!=0) begin //将这条信息插入数据库中 insert into A(列名集合) select 列名集合 from inserted end
在插入时判断就行了! 直接.net中 判断 if(amount!=0) { //插入 }
触发器有一个beforeinsert可以实现你的要求
Create Trigger truA On A --在A表中创建触发器 for Insert --插入触发器 As if (amount=0) --条件匹配 触发该事件 begin Insert into A value (A表的值) end
on A
instead of insert
as
declare @amount int
set @amount=(select amount from inserted)
if(@amount!=0)
begin
//将这条信息插入数据库中
insert into A(列名集合) select 列名集合 from inserted
end
直接.net中 判断
if(amount!=0)
{
//插入
}
Create Trigger truA
On A --在A表中创建触发器
for Insert --插入触发器
As
if (amount=0) --条件匹配 触发该事件
begin
Insert into A value (A表的值)
end