Hi,
I was wondering if someone had any suggestions as to how to make this work without a cursor.
Thanks much
I was wondering if someone had any suggestions as to how to make this work without a cursor.
Thanks much
Code:
create TRIGGER [tgr_ExportHomesExceptionsHistory]
ON [dbo].[ExportHomesExceptions]
FOR DELETE, UPDATE
AS
BEGIN
SET NOCOUNT ON;
DECLARE @HomeIdDeleted int
DECLARE HomeIdDeleted_Cursor Cursor For
select HomeId from deleted
OPEN HomeIdDeleted_Cursor
FETCH NEXT FROM HomeIdDeleted_Cursor
INTO @HomeIdDeleted
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO ExportHomesExceptionsHistory (HomeId, CustId, LpPartnerCode,
DateAdd, DateMod, ActionBy, Locked)
(Select HomeId, CustId, LpPartnerCode, DateAdd, GetDate(),ActionBy, Locked
from deleted where HomeId=@HomeIdDeleted)
IF (SELECT HomeId FROM deleted WHERE LpPartnerCode = 'ReAffinity'
OR LpPartnerCode = 'Edgeio' AND HomeId=@HomeIdDeleted) <> 0
BEGIN
UPDATE Homes Set ChgDate = GetDate() where HomeId = @HomeIdDeleted
END
FETCH NEXT FROM HomeIdDeleted_Cursor
INTO @HomeIdDeleted
END
CLOSE HomeIdDeleted_Cursor
DEALLOCATE HomeIdDeleted_Cursor
END