Oh all right then. No funny stuff either.
DECLARE @ItemID INT
DECLARE @FirstCol varChar(5), @SecondCol INT, @ThirdCol Char(1)
SET @ItemID = 1
UPDATE #Testing SET ThirdCol = CASE @ItemID WHEN 1 THEN 'D' ELSE ThirdCol END,
@ItemID = CASE WHEN @FirstCol = FirstCol AND @SecondCol = SecondCol AND @ThirdCol = ThirdCol THEN @ItemID+1 ELSE 1 END,
@FirstCol = FirstCol, @SecondCol = SecondCol, @ThirdCol = ThirdCol
DELETE FROM #Testing WHERE ThirdCol = 'D'
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden