sql trigger to call stored procedure with parameters 1

sql trigger to call stored procedure with parameters

 DECLARE @OrderNumber NVARCHAR(150);
 IF EXISTS(SELECT * FROM INSERTED)
    BEGIN
    SELECT @OrderNumber=i.OrderNumber FROM inserted i;
 	EXEC [dbo].[YOUR_STOREPROCEDURENAME]
          @InGuidKey = N'',
          @InParameter1 = '',
		 @InParameter2 = '',
         @InDebugModeOn = N'0'
    END

Here is what the above code is Doing:
1. It’s checking to see if there are any rows in the INSERTED table. If there are, it will execute the stored procedure.
2. It’s passing in the OrderNumber from the INSERTED table to the stored procedure.
3. It’s passing in the other parameters that the stored procedure needs.
4. It’s passing in a debug mode parameter. This is a parameter that I use to determine if I want to see the output of the stored procedure. If I set it to 1, I will see the output. If I set it to 0, I won’t see the output.

Similar Posts