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 |
|
ameya_amu
Starting Member
25 Posts |
Posted - 2008-08-04 : 06:23:23
|
| hello friendi have three table 1) Artical_Demanded2) Artical_Received3) Artical_InStockArtical_Demanded table contain the details of the artical demanded from manufacturerwhich have following fieldAID(pk),artical_id,quantity_demanded,dateofdemand,quantity_receivedartical_received table contain details of the artical received from manufacturewhich has following fieldsartical_id,AID,quantity_received,dateofreceipt,rateperartical ( there can be multiple record for AID)artical_inStock table contain detail of current avaliable stock of particular articalartical_id,instockif any record is inserted in artical_received table then quantity_received of artical_Demand table must be incremented and instock field of artical_instock must be also incremented.can any one tell me how to use trigger. when rows are updated in artical_received table(respective changes must be made in artical_demanded and artical_instock |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-04 : 10:55:16
|
| [code]CREATE TRIGGER yourTriggerON Artical_ReceivedAFTER INSERT,UPDATEASUPDATE adSET ad.quantity_received=ad.quantity_received+i.quantity_receivedFROM inserted iINNER JOIN Artical_Demanded adON ad.AID=i.AIDUPDATE adSET ai.instock=ai.instock+i.quantity_receivedFROM inserted iINNER JOIN artical_inStock aiON ai.AID=i.AIDGO[/code] |
 |
|
|
|
|
|