I am trying to call an IF statement on my trigger so it won't archive expired files. (I only want to keep files that have been deleted but have not been expired)
My error is The multi-part identifier "d.ExpiryDate" could not be bound.
My Code:
ALTER TRIGGER [dbo].[ArchiveDB]
ON [dbo].[TBL_Content]
AFTER DELETE
AS
BEGIN
declare @ContentID int
set @ContentID = (select ContentID from deleted)
IF (d.ExpiryDate > getDate() )
begin
insert into ArchiveBackup.dbo.TBL_Deleted_Content
(ContentID, StartDate, ExpiryDate, Title... etc)
select
d.ContentID,d.StartDate,d.ExpiryDate,d.Title... etc
from deleted as d
end
END
Thanks for the help!