October 31st, 2012, 01:25 AM
Trigger with multiple lines
Good day. What am I trying to achieve is when line in Sales Line table in Navision is deleted then insert data from deleted record to new table.
This is working fine (with the code below) if I delete one single line, however not working for multiple lines. Can you help me to do same functionality for multiple lines.
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
ALTER TRIGGER [dbo].[KkSalesLines]
ON [dbo].[Sales Line]
DECLARE @document_no nchar(20)
DECLARE @line_no nchar(20)
SET @document_no = (SELECT [Document No_] FROM deleted)
SET @line_no = (SELECT [Line No_] FROM deleted)
INSERT INTO DeletedSalesLine
October 31st, 2012, 04:45 AM
create trigger [dbo].[KkSalesLines] on dbo.[Sales Line] after delete as
insert into DeletedSalesLine
select [Document No_],
October 31st, 2012, 07:09 PM
Thank you very much. Can't believe it was so simple.