quote: Originally posted by pootle_flump What about a CTE?
Turns out it is fine.use tempdbgocreate table #sales ( productid int , storeid int , dbrowid int , seqid int , linkseqid int )insert into #sales (productid, storeid, dbrowid)select 752534, 4, 1union all select 752534, 4, 2union all select 752534, 4, 3union all select 896784, 2, 4union all select 896784, 2, 5union all select 896784, 4, 6union all select 898874, 2, 7union all select 898968, 2, 8gowith rnsas( select productid , storeid , row_number() over (partition by productid , storeid order by productid , storeid) as row_num from #sales)update sset seqid = row_numfrom #sales as sinner join rnson rns.productid = s.productid and rns.storeid = s.storeidselect * from #salesdrop table #sales |