create trigger deltrigger on employee for delete as if @@rowcount=0 return if @@rowcount>1 begin rollback transaction raiserror('you can only delete one information at one time',16,1) end return
什么时候会弹出raiserror('you can only delete one information at one time',16,1)的提示信息,if @@rowcount=0 return不理解, if @@rowcount>1 begin rollback transaction raiserror('you can only delete one information at one time',16,1) end 是说删除的行数大于一行的话就执行begin----end 中的语句麻?还是另有意思?
drop trigger upord go create trigger upord on orders after update as declare @row int set @row = @@rowcount if @row = 0 return if (update(p_name)) begin if @row > 1 begin rollback transaction raiserror('you can only one information at one time',16,1) end return update p set p.p_name = i.p_name from product p,inserted i,deleted d where p.p_name = d.p_name end