You could try combining the logic to the update. Something like (don't mind the typos):
UPDATE Data SET Field = @newfieldval
WHERE ID = @rowID
AND ( 1 = (SELECT UpdateSetting FROM Setting WHERE ID = @fieldid)
OR ( 1 = (SELECT UpdateSetting FROM Setting WHERE ID = @fieldid)
AND IS NULL (SELECT field FROM Data WHERE id = @rowID)))
However, few considerations: - where does the rowid come from, could you eliminate that variable - as I understood that this is from inside the trigger, what happens if several rows are updated If you're using SQL Server, I would combine the previous statement with inserted (and perhaps deleted) table table if possible. That would help to make the whole update process a single batch. Also don't forget about good indexing. Hope it helps, Mika
The need to optimize rises from a bad design.My articles[^]