UPDATE STOKKARTI  SET Barkodu = Kodu
where Barkodu in (select Barkodu  STOKKARTI_BARKODU from STOKKARTI     GROUP BY Barkodu   HAVING COUNT (Barkodu   )>1)
  and LEFT(Kodu,16) = Barkodu
GO
DELETE StokBarkodlari WHERE  ISNULL(Barkodu,'') = '' 
GO
UPDATE StokBarkodlari  SET Barkodu = StokKodu
where (LEFT(StokKodu,16) = Barkodu and Barkodu in (select Barkodu from StokBarkodlari      GROUP BY Barkodu   HAVING COUNT (Barkodu)>1))
GO
update s1 SET  s1.SiraNo = s2.Rank from StokBarkodlari s1, (select *,DENSE_RANK() OVER  (PARTITION BY StokKodu ORDER BY AnaBirim DESC,Barkodu ) AS Rank  from StokBarkodlari) s2
where s1.StokBarkodlariNoId = s2.StokBarkodlariNoId