You can do it like this:
Creating temp table and inserting test values
create table #temp
(Receipt_key varchar(10),
Item_key varchar(10) ,
Position int);
insert #temp
values
('0001','02654',NULL),
('0001','35544',NULL),
('0002','02654',NULL),
('0002','85466',NULL),
('0002','84945',NULL)
Final update statement
WITH upd_recs
AS (SELECT Receipt_key,
Item_key,
Row_number()
OVER (
partition BY Receipt_key
ORDER BY Receipt_key, Item_Key) rnk
FROM #temp)
UPDATE #temp
SET Position = rnk
FROM upd_recs a
INNER JOIN #temp b
ON a.Receipt_key = b.Receipt_key
AND a.Item_key = b.Item_key
Hope this is what you are looking for?
~ Lokesh Vij
Link to my Blog Post --> www.SQLPathy.com[/url]
Follow me @Twitter