INSTEAD OF triggers do not support direct recursion

Posted by senzacionale on Stack Overflow See other posts from Stack Overflow or by senzacionale
Published on 2010-06-05T09:17:00Z Indexed on 2010/06/05 9:22 UTC
Read the original article Hit count: 485

Filed under:
ALTER TRIGGER [dbo].[TRG_DeleteUser]
ON [dbo].[Users] 
INSTEAD OF DELETE
AS
BEGIN
SET NOCOUNT ON
    DECLARE @AspNetUserGuid UniqueIdentifier
    DECLARE @UserId NVARCHAR(36)
    BEGIN
        SET @AspNetUserGuid = (SELECT AspNetUserGuid FROM deleted)  
        SET @UserId = (SELECT UserId FROM dbo.Users WHERE AspNetUserGuid = @AspNetUserGuid)         
        IF @AspNetUserGuid IS NOT NULL AND @UserId IS NOT NULL
        BEGIN   
            EXECUTE [dbo].UsersDelete @AspNetUserGuid, @UserId
        END
    END
SET NOCOUNT OFF
END

problem is here: EXECUTE [dbo].UsersDelete @AspNetUserGuid, @UserId i need to call triger before row is actually deleted-

© Stack Overflow or respective owner

Related posts about tsql