Link to home
Start Free TrialLog in
Avatar of Roger Alcindor
Roger Alcindor

asked on

update trigger for single record

Is there any way that I can restrict the application of an update trigger to the record that has been updated and not each record in the whole table ?
I am concerned that when the table grows to a large size then the trigger will be wasting time by checking each record in the table when I only require the record that has just been updated to be acted upon by the update trigger.

The trigger checkes some other fields in the same table and updates a field in the dsame table

Thanks,

Roger

Avatar of auke_t
auke_t
Flag of Netherlands image

In the trigger you can use the Inserted and Deleted tables to make sure only the affected records are updated.

Check Books online for more information!

Good luck!
yes you can do something like this
Create trigger yourtrname
for update
as
if update(yourfield)
begin
   yourcode
end
Avatar of Mr_Peerapol
Mr_Peerapol

> Is there any way that I can restrict the application of an update trigger to the record that has been updated
Use inserted and/or deleted system tables. inserted table contains records being updated with new value, while deleted table contains records being updated with old value.

Avatar of Roger Alcindor

ASKER

The if update(yourfield) answer is not what I am looking for.
It sounds like the inserted/deleted tables may be the answer but I can't find the tables on my server ?
Are they only visible during a trigger event ?

Roger
ASKER CERTIFIED SOLUTION
Avatar of Mr_Peerapol
Mr_Peerapol

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial