create table #holding( SDPRGR varchar(10), SDDOC int)insert into #holdingselect 'PHARM', 1293931 union allselect 'PHARM', 1293931 union allselect 'OTC', 0 union allselect 'OTC', 0 union allselect 'PHARM', 1293931 union allselect 'HH', 1293939 union allselect 'OTC', 1293938update h set SDDOC = (select top 1 SDDOC from #holding x where x.SDPRGR = h.SDPRGR and SDDOC <> 0)from #holding hwhere SDDOC = 0select * from #holding
-----------------'KH'if you can't beat them, have someone else to beat them