Afficher un message
Vieux 12/01/2008, 15h28   #5
SagiPhoenix@AlbionLab
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Create Delete Trigger on Table1 to Update a filed on Table2

ad the condition of the deleted deleted record's identity ID to the
update statement. the ID can be fetched using

select @recKeyID = {identity column name} from deleted

the @recKeyID is the variable you need to create.

SagiPhoenix@AlbionLab


Yas wrote:
> Hi everyone
>
> I am trying to create a DELETE Trigger. I have 2 tables. Table1 and
> Table2. Table 2 has all the same fields and records as Table1 + 1
> extra column "date_removed"
>
> I would like that when a record is deleted from Table 1, the trigger
> finds that record in Table2 and updates the date_removed filed with
> current time stamp.
> The primary key on both is combination of domain,admin_group and cn.
>
>
> CREATE TRIGGER [tr_updateTable2] ON [dbo].tbl_Table1
> FOR DELETE
> AS
> Update Table2
> SET date_removed = getDate()
>
> I'm stuck here, how do I manipulate on Table2 only the records that
> were deleted on Table1, so to only update date_removed filed for them
> in Table2?
> I guess i need to compare domain, cn and admin_group, but I don't know
> how.
>
>
> Any would be greatly appreciated
>
> Thanks! :-)

  Réponse avec citation
 
Page generated in 0,04713 seconds with 9 queries