Skip to content
Advertisement

After update trigger not updating specific row of data in SQL table

Fairly new to SQL here… I am trying to get an ‘after update’ trigger in SQL Server to update a column (rig_ident) whenever another column (rig_id) is updated. rig_ident is found by searching the rig_log table.

With the below code it works, but I’m worried it may be running through every row in the table and checking accordingly, which would be a waste of processing and time! Can anyone provide suggestions on how to do this properly?

Advertisement

Answer

Your trigger is broken (as the comment suggests) because you are assuming that only one row is being updated/inserted. But SQL Server triggers work on sets of rows, not on individual rows.

I think you can replace the logic with:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement