Questions

SQL Trigger with store procedure.

+
0 Votes
Locked

SQL Trigger with store procedure.

EVGA
Looking for best practices and insight for SQL triggers.

1. Even though I have 1 record inserts, updates should I write multiple record queries and why?

2. During a trigger which has quite a bit of different inserts and things going on is it better to write a store procedure to be called from the trigger to handle this vs the trigger directly handling this and why?

Any other performance recommendations?
  • +
    0 Votes
    Slayer_

    But for question two, I'd say it depends on what the trigger is doing. And if its something a user or application would need to run separately.
    For example, say you made a trigger that created a new database backup each time it was run.
    If an application needs this functionality, you should make it a stored proc, otherwise, a trigger is just fine.

    That's my take on it anyways, but I am no DBA.

  • +
    0 Votes
    Slayer_

    But for question two, I'd say it depends on what the trigger is doing. And if its something a user or application would need to run separately.
    For example, say you made a trigger that created a new database backup each time it was run.
    If an application needs this functionality, you should make it a stored proc, otherwise, a trigger is just fine.

    That's my take on it anyways, but I am no DBA.