Hi everbody.
I have two tables. Table A has a field called SumQtd and Table B has a field Qtd.
Table A has one record and table B has none, one or more records. The sum of B.Qtd must be stored in A.SumQtd.
I was wondering how to create a Trigger (or other way, no matter here) to do this job for me.
It is so simple if I were using VFP, but I'm starting with SQL and I have no idea how to do this.
Every change at Table B should fires something like this "Select Sum(Qtd) From TableB Where MyId = Inserted.MyId". and then: Update TableA Set SumQtd = 'ThatNumber' Where MyId = InsertedMyId. It should be soooo simple, shouldn't it?
So, I need to calculate it every time a record is inserted, updated or deleted from Table B, so, I wonder I will have to use Inserted and Deleted temp tables, don't I?
Any help is appreciate!
Thanks in advanced!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Rodolfo Duarte