I'm trying to execute the following SQL query to update a column called seq
with numbering sequence for a particular id but it throws an error:
Incorrect syntax near the keyword 'ORDER'.
DECLARE @id INT
SET @id = 0
UPDATE T_TRNHIST
SET @id = seq = @id + 1
WHERE Acc='12344'
OPTION ( MAXDOP 1 )
ORDER BY Recid, trnDate
Where could I have gone wrong?