I'm getting the following error after creating a trigger in SQL Server, i have researched this error and tried so many different things but nothing has worked.
Microsoft OLE DB Provider for SQL Server error '80040e14' Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)
USE [admin_W4F]
GO
/****** Object: Trigger [lee2121].[discount] Script Date: 6/7/2019 10:45:55 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [lee2121].[discount]
ON [lee2121].[Cart]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
update [lee2121].Cart
set totalprice2 = [lee2121].[Cart].[price] - ([lee2121].[Cart]. [price]/[lee2121].[Cart].[disc])
END
Don't use a trigger for this! Just use a computed column:
alter table [lee2121].[Cart]
add totalprice2 (price - (price / disc);
The value will be calculated when the table is queried. The values will always be up-to-date.
It looks like your trigger is firing your trigger? Try adding NOT FOR REPLICATION
so in the end i have gone with a computed column which seems to be working fine, i used this code;
([price]-[price]/[disc])
Thank you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.