INSERT INTO  StokBarkodlari (StokKodu,Barkodu,KulNo,Carpani,UpdateDate,StokNo,AnaBirim,Birim)
Select Kodu,Barkodu,1,1,GETDATE(),StokNo,1,sk.AnaBirim from STOKKARTI sk
where NOT EXISTS (Select 1 from  StokBarkodlari sb where sk.Kodu = sb.StokKodu)

GO

INSERT INTO  StokBarkodlari (StokKodu,Barkodu,KulNo,Carpani,UpdateDate,StokNo,AnaBirim,Birim)
Select Kodu,Barkodu,1,1,GETDATE(),StokNo,1,sk.AnaBirim from STOKKARTI sk
where NOT EXISTS (Select 1 from  StokBarkodlari sb where sk.Kodu = sb.StokKodu or sk.Barkodu = sb.Barkodu)

GO 

UPDATE sb SET sb.StokNo = sk.StokNo from STOKKARTI sk,StokBarkodlari sb
where sk.Kodu = sb.StokKodu and sk.StokNo <> sb.StokNo
