这是我的触发器代码SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO ALTER trigger Insert_xfjl_max on xfjl for insert as if ((select sum(xfje) from xfjl where datepart(dd,xfsj)=day(getdate()) and datepart(m,xfsj)=month(getdate()) and datepart(yyyy,xfsj)=year(getdate()) and kpbh = (select kpbh from inserted))> 50) begin print '超出当天最大消费了' rollback; else begin commit print '执行成功' end GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO 写储存过程该怎么改呢?
摁锕,trigger不常用来干这个。
GO
SET ANSI_NULLS ON
GO
ALTER trigger Insert_xfjl_max
on xfjl
for insert
as
if ((select sum(xfje) from xfjl where datepart(dd,xfsj)=day(getdate())
and datepart(m,xfsj)=month(getdate()) and datepart(yyyy,xfsj)=year(getdate()) and kpbh = (select kpbh from inserted))> 50)
begin
print '超出当天最大消费了'
rollback;
else
begin
commit
print '执行成功'
end
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
写储存过程该怎么改呢?