question

sql_updates avatar image
sql_updates asked

Importance of triggers

How the magic tables will be created?
t-sqltrigger
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
WilliamD avatar image
WilliamD answered
If I understand you correctly, you want to know how the "magic" tables `inserted` and `deleted` are created when a trigger is created. These tables are internal system tables that you do not create by hand - they basically give you read-only access to the previous state of a row when you have made a change. They offer up the same columns as the base table the trigger has been created on, just with the data as it was before deletion/update or for inserts, the exact data that has been inserted. You can then use this information to start a secondary process behind the scenes. One word of warning though - triggers can be a hidden source of great performance pain - if you have to do asynchronous data processing, use service broker or a hand rolled asynch process. A trigger can and will slow down an in-flight transaction, just about everything you can think of putting in a trigger can be done outside of one.
6 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

wow, they should have had you on the team working on the Rosetta Stone, it would have been translated in a couple of hours. :)
2 Likes 2 ·
@Fatherjack - perhaps @WilliamD worked at Bletchley Park in a previous life...
1 Like 1 ·
thx for your information ..
0 Likes 0 ·
@ThomasRushton If I told you.... you'd have to buy me a beer :o) I have learned to decipher things like this through talking with people who wanted to practice their english.
0 Likes 0 ·
@WilliamD - I think I may need to do that anyway. :-)
0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.