1

Topic: The trigger - total recalculation is necessary

please to write the trigger
There are two tables connected on key ID_DOG
DOGOVOR_PL_USL - Head - a total amount on ID_DOG in it
DOGOVOR_MTD - The subordinate - field PRICE contains the current total
It is necessary at change of field D_VPZVRAT in DOGOVOR_MTD to enumerate a total amount in
DOGOVOR_PL_USL
It is impossible to me:
ALTER TRIGGER [dbo]. [tr1_DOGOVOR_MTD]
ON [dbo]. [DOGOVOR_MTD]
AFTER UPDATE
AS
if update (D_VOZVRAT)
BEGIN
SET NOCOUNT ON;
declare @@ id BIGINT
set @@ ID = (select ID_DOG from DOGOVOR_MTD)
UPDATE DOGOVOR_PL_USL
set SUMMA = (select sum (price) from DOGOVOR_MTD where id_dog = @@ ID AND d_vozvrat IS NULL group by id_dog)
----where id_dog = @@ ID

2

Re: The trigger - total recalculation is necessary

To read about tables inserted and deleted