none
SP inside a Trigger

    Question

  • I want to execute the stored procedure inside the trigger if something has changed in regards to the information I pass to the Store Procedure.

    For Example in my table :

    I have Name, Address, Phone, Email

    So, if Name is different in INSERTED and DELETED, then I need to fire the Store Procedure otherwise do nothing


    Wednesday, April 24, 2013 4:57 PM

Answers

  • Are you sure you need this in the trigger? Can you modify the command that updates the table to call this SP afterwards? You'll have access to these tables using OUTPUT clause of the UPDATE command.

    In any case, you will need a cursor loop to run this SP for every row.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

    Wednesday, April 24, 2013 5:08 PM

All replies

  • Are you sure you need this in the trigger? Can you modify the command that updates the table to call this SP afterwards? You'll have access to these tables using OUTPUT clause of the UPDATE command.

    In any case, you will need a cursor loop to run this SP for every row.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

    Wednesday, April 24, 2013 5:08 PM
  • ...
    ...
    exec StoredProcedureName @param = @value
    ...
    ...

    By the way it is not recommended to have triggers call procedures


    Please mark my post as Answer or as Helpful if it helps you

    Wednesday, April 24, 2013 8:13 PM