DECLARE @I INT=584297
select IslemNo ,IslemNo3 ,* from STOKHAR where @I IN (IslemNo,IslemNo3)
select TevkifatTutari from STOKHARDETBAG where IslemNo in (select IslemNo  from STOKHAR where @I IN (IslemNo,IslemNo3))
SELECT * FROM Tevkifat where  IslemNo in (select IslemNo  from STOKHAR where @I IN (IslemNo,IslemNo3))


SELECT top 5 TevkifatAdi,TevkifatKod,TevkifatOrani,TevkifatTutari,* FROM STOKHARDETBAG WHERE TevkifatTutari>0
go
SELECT * FROM tblTevkifat 
select * from Tevkifat
go
SELECT        IslemNo, IslemTuru, FaturaTarihi, TevkifatAdi, TevkifatKod, TevkifatOrani, TevkifatTutari FROM TevkifatSHD 
go
insert into Tevkifat (	IslemNo	,StokNo,	Kod,	TevkifatOrani,	TevkifatTutari)  
select  t.IslemNo, StokNo ,TevkifatKod, TevkifatOrani, TevkifatTutari  from  TevkifatSHD t,STOKHAR s 
where t.IslemNo=s.IslemNo and TevkifatTutari>0


 delete from TevkifatSHD where TevkifatTutari= 0 and TevkifatOrani=0
select * from  Tevkifat
UPDATE STOKHAR SET StokNo =(SELECT StokNo FROM STOKKARTI WHERE Kodu=STOKHAR.StokKodu)
update Tevkifat set StokNo=(select TOP 1 StokNo from STOKHAR WHERE (IslemNo=Tevkifat.IslemNo OR IslemNo3=Tevkifat.IslemNo) AND StokNo <> '')

SELECT StokNo,Kodu FROM STOKKARTI ORDER BY StokNo

