Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JacobPressures
Posting Yak Master
112 Posts |
Posted - 2005-08-15 : 14:22:30
|
| Question 1Regarding this statement: "A table can have multiple AFTER triggers of a given type provided they have different names; each trigger can perform numerous functions. However, each trigger can apply to only one table, although a single trigger can apply to any subset of three user actions (UPDATE, INSERT, and DELETE)."So basically everywhere i have a LastUpdated column i will have to cut and paste the same trigger for that table. I was wondering that. I meantion this because i was wondering if there was a better way to do this than cut and paste. Cut and paste just seems a little redundant!Question 2Inserted and Deleted tables are created as information is inserted, updated and deleted from tables. How long does such info stay in memory, when is it lost? What happens when you insert into one table, then insert into another table and then go back and insert into the first table again? Does it retain all the information inserted each time?Thanks! |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-08-15 : 15:09:24
|
| Question 2)I don't know when the physical memory taken by inserted and deleted tables is released butfrom a developers perspective, those tables are only available to the trigger that's firing. So when the trigger code is done, the inserted and deleted tables are (gone). The next transactionhas different inserted and deleted tables. Doesn't matter if its another concurrent user or a series of transactions from the same user, each transaction has a different set ofinserted and deleted tables.Question 1)If you are handling the LastUpdated column with a trigger than you'll need a seperate triggerfor each table with that column. Whether you type out the code manually, cut and paste it, or generate it with a tool is up to you and your abilities/enginuity. As a possible alternative: If all your table inserts/updates/deletes came from stored procedures and you didn't allow direct table access to users than you could avoid triggers and put the LastUpdated logic in the stored procedures.Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|