I'm trying to increase the rowno column in the detail file for each detail inserted.
Increase the RowNo column in the detail table (on insert) based on the ParentID and the MAX row for the related detail records using a trigger, however, this does not appear to be working. All RowNo for the related details are updating when the trigger fires.
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
ALTER TRIGGER [Citations].[trg_LogDetail_NewRowNo]
SET NOCOUNT ON;
SET RowNO = (SELECT MAX(rowno) FROM Citations.LogDetails WHERE ParentLogNo = i.ParentLogNo) +1
FROM Citations.LogDetails S INNER JOIN Inserted I
ON S.ParentLogNo = I.ParentLogNo
WHERE I.ParentLogNo = I.ParentLogNo