Hello,
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.
Trigger
USE [TR_DB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [Citations].[trg_LogDetail_NewRowNo]
ON Citations.LogDetails
AFTER INSERT
AS
BEGIN
SET NOCOUNT ON;
UPDATE Citations.LogDetails
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
END
GO
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.