Hi @Jim Seidel ,
Please refer below:
declare @temp table
(
ID int,
ReplyID int,
[NewID] int,
ClientID int
)
insert into @temp values
(99,70,NULL,138),
(100,71,NULL,138),
(101,95,NULL,108),
(137,111,NULL,31),
(138,111,NULL,31),
(139,111,NULL,31)
select ID,ReplyID,[NewID]=ROW_NUMBER() OVER(PARTITION BY ReplyID ORDER BY ID) ,ClientID
from @temp
Output:
ID ReplyID NewID ClientID
99 70 1 138
100 71 1 138
101 95 1 108
137 111 1 31
138 111 2 31
139 111 3 31
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues November--What can I do if my transaction log is full?
Hot issues November--How to convert Profiler trace into a SQL Server table