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 |
|
sonjan
Starting Member
22 Posts |
Posted - 2012-07-26 : 00:57:20
|
| HiHaven't created either of above and upon researching stored procedures and triggers, not sure which is best practice to use.Aim: replacement cost in assetfinbook table is changed, then push that value to replacement cost in asset table IF asset resides in specified site id and status.Wise advice is very much appreciated.ThanksSonja |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2012-07-26 : 01:35:28
|
| Trigger will be fired automatically on events list INSERT, UPDATE or DELETE, while for stored procedure you have to execute it. So if you need to take action on each record (INSERT, UPDATE or DELETE) then go for trigger, and if you need to update your data in batch later on, then go for stored procedure.--------------------------http://connectsql.blogspot.com/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-26 : 10:04:28
|
| Trigger can be actually consider as a special kind of procedure which will get executed based on an event (DDL/DML/LOGON) If your DML process is streamlined (ie INSERT/UPDATE/DELETE taking place only through procedure) then you can enclose the logic in procedure itself otherwise if you've no control over how DML operations happens then go for the trigger approach------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2012-07-26 : 23:41:06
|
| A word of warning on triggers - they have the ability to make systems very confusing with strange events and updates happening for no apparent reason (if you're not aware of them). You can also inadvertently gum up the works quite nicely by doing things all the time that maybe should happen selectively.To me that sounds like a business rule best done in a SP or the business layer.If you use triggers at all, I'd strongly recommend them for system level type stuff (logging row update before & after etc) and little, if anything, else. |
 |
|
|
sonjan
Starting Member
22 Posts |
Posted - 2012-07-27 : 00:30:04
|
| Thank you all for your advice. I am skeptical of triggers will do some more research.RegardsSonja |
 |
|
|
|
|
|