Execute a store procedure when the table is modified

  • I need to exceute an store procedure when a row is inserted in a table and when a row is deleted and when a row is updated.

    How can I do That?

    I want that the execution of the store procedure is transparent to the user.

    Thanks

    Viky

  • Do you want the stored procedure to execute after each row updated, inserted, deleted or after each transaction? Example: If a user inserts 10 rows in a transaction do you want the stored procedure to execute once or ten times? A trigger would do the job.

  • That's exactly what triggers are for. You can look up triggers in BOL to find out more.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Ken Jr. (5/4/2011)


    Do you want the stored procedure to execute after each row updated, inserted, deleted or after each transaction? Example: If a user inserts 10 rows in a transaction do you want the stored procedure to execute once or ten times? A trigger would do the job.

    Doing it once per transaction is the only way to go.

    You can break up the processing into smaller chunks within the stored procedure itself, if you really need to.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply