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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Trigger HELP

Author  Topic 

tishri
Yak Posting Veteran

95 Posts

Posted - 2006-12-15 : 22:10:30
Hey guys I need help with triggers.

This is my table diagram.


[Accounts Table] [Payments Table]
Account_ID (Primary) Relate to => Account_ID
Balance as Money Date Paid [PaymentDetails Table]
PaymentsDetail_ID Relate to ==> PaymentsDetail_ID
Description
Amount_Paid


All tables have recursive update and delete.

when delete action is invoked in [paymentdetails table] i can successfully update the balance in accounts table but when delete action is invoked in [payments table] i cannot update balance in accounts table.

Can you suggest a trigger query so that i can update the balance in accounts table.




TCC

TCC

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-15 : 23:58:58
Duplicate Post:
[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76488[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

tishri
Yak Posting Veteran

95 Posts

Posted - 2006-12-16 : 19:07:41
Can you help me guys build the trigger for UPDATE,DELETE,INSERT in [payments table] and [paymentsdetail table] so that it will update the [balance] in [accounts table] ...

ON INSERT
balance = balance + amount_paid

ON DELETE
balance = balance - amount_paid

need help really.....

TCC
Go to Top of Page

madhuotp
Yak Posting Veteran

78 Posts

Posted - 2006-12-17 : 13:05:29
can u post u r trigger script. in delete trigger u should refer Deleted table.

Madhu
Go to Top of Page
   

- Advertisement -