I have 3 tables, let's say Table A, Table B and Table C.
I have a trigger on Table A which inserts data into Table B, and I also have a trigger on Table b which inputs data into Table C. On Table C, there's a trigger that executes a procedure.
The task is that even if something happens during the operations on the Table C i.e (any error occurs), the operations on Table A, B and C should continue and complete. The problem is that if something goes wrong on procedures, the operations on table A, B and C are aborted as well.
My table C trigger is :
CREATE TRIGGER [dbo].[Trg_Mst_TableC]
ON [dbo].[TableC]
FOR UPDATE
AS
BEGIN
DECLARE @flg_Error INT
SET @flg_Error = 0
DECLARE @SLQString NVARCHAR(MAX)
SELECT @SLQString = 'Text Message'
SAVE TRANSACTION MySavePoint
IF ISNULL(@SLQString, '') <> ''
BEGIN
EXEC spMsc_SendMsg 'Test', 'POST', @SLQString
IF @@error <> 0 BEGIN
ROLLBACK TRAN MySavePoint
END
END
END
Here is my procedure :
CREATE PROCEDURE [dbo].[spMsc_SendMsg]
@msg_type NVARCHAR(50),
@getpost NVARCHAR(20),
@msg_txt NVARCHAR(MAX)
AS
BEGIN
SET NOCOUNT ON
SAVE TRANSACTION MySavePoint
CREATE TABLE Test (XXX NVARCHAR(MAX))
SELECT @msg_type, @getpost, @msg_txt
END
Now this procedure returns error msg for "Test" table. But i need to save the remaining transaction done till Trigger C. Please give me solution for this.