Hi @John
Thanks for reaching out to the Microsoft Q & A Forum.
The issue occurring in Production, where outdated child records are being inserted into the Audit Log table, is due to a logic error in the update trigger on the child table. Specifically, the trigger appears to join the INSERTED and DELETED pseudo-tables on a non-unique column like ParentID or assumes only single-row updates. Since Production often updates multiple child rows for the same parent at once, this results in incorrect mapping and unrelated records being logged. To address this, the trigger should be revised to join on the primary key such as ChildID and process updates in a set-based manner. Audit logic should only capture fields that are truly modified, and the stored procedure should update rows only when data changes. Utilizing the SQL Server OUTPUT clause in the stored procedure to record changes directly into the audit table is recommended for improved reliability. Ultimately, correcting the row-mapping logic in the trigger or moving audit functionality to the stored procedure will resolve the issue.
I hope this information helps. Please do let us know if you have any further queries.
Thank you