This might perform a little better-- prepare test datadeclare @t table (rowid int identity(1, 1), colA int, colB int, peso int)insert @t (colA, colB)select 1, 1 union allselect 0, 1 union allselect 0, 1 union allselect 9, 9 union allselect 0, 2 union allselect 2, 2-- do the workupdate t1set t1.peso = (select top 1 t2.colA from @t t2 where t2.rowid <= t1.rowid and t2.cola <> 0 order by t2.rowid desc)from @t t1select * from @t
Peter LarssonHelsingborg, Sweden