'Inserted' & 'Deleted' tables are temporary table created by Sql
These tables have same structure as Main table
Their scope is in triggers
These can be used for validation or other calculation or as required in triggers
Example :
ALTER TRIGGER [dbo].[Reminder]
These tables have same structure as Main table
Their scope is in triggers
These can be used for validation or other calculation or as required in triggers
Example :
ALTER TRIGGER [dbo].[Reminder]
ON [dbo].[Filings]
AFTER UPDATE
AS
declare @FilingId as int
declare @FilingSId as int
declare @IsOnTime as bit
SELECT @FilingId = i.FilingId FROM INSERTED i
SELECT @FilingSId = i.filingstatus FROM INSERTED i
SELECT @IsOnTime = case when getdate() > A.DueDate then 0 else 1 end from vw_Companies A inner join INSERTED i on A.crno = i.crno
IF ( UPDATE (filingstatus) and @FilingSId =12)
BEGIN
update Filings set isontime = @IsOnTime where filingid = (select i.FilingId FROM INSERTED i)
END;
No comments:
Post a Comment