DEKONT Belge kalem kayitlari düzenlenirken hata
SQL : INSERT INTO ##TMPEDEFTER ( BELGE_TIPI, BELGE_NO, TARIH, AYSIRA, MUHSIRA, MUHFISNO, I_YEDEK1, S_YEDEK1, MUHAY_KODU, SUBE_KODU, KAYNAKDOVKUR )
SELECT
( CASE WHEN CEKSENDEK.DEKONT_PRGNO IN (3,6, 35, 36, 45, 46) THEN (CASE WHEN CEKSENDEK.CEKSENTIP IN (1,2) THEN 'Ç.Tah' ELSE 'S.Tah' END )
WHEN CEKSENDEK.DEKONT_PRGNO IN (4,5) THEN (CASE WHEN CEKSENDEK.CEKSENTIP IN (1,2) THEN 'Ç.Pro' ELSE 'S.Pro' END )
WHEN CEKSENDEK.DEKONT_PRGNO IN (7,8,16) THEN (CASE WHEN CEKSENDEK.CEKSENTIP IN (1,2) THEN 'Ç.Kar' ELSE 'S.Kar' END )
WHEN CEKSENDEK.DEKONT_PRGNO IN (10,49) THEN (CASE WHEN CEKSENDEK.CEKSENTIP IN (1,2) THEN 'Ç.Ode' ELSE 'S.Ode' END )
WHEN CEKSENDEK.DEKONT_PRGNO = 11 THEN (CASE WHEN CEKSENDEK.CEKSENTIP IN (1,2) THEN 'Ç.Iade' ELSE 'S.Iade' END )
ELSE ''
END) BELGE_TIPI,
(CEKSENDEK.FISNO) BELGE_NO,
(CEKSENDEK.ISLEM_TARIHI) TARIH,
ROW_NUMBER() OVER (ORDER BY MUHFIS.TARIH, MUHFIS.FISNO,BA,HES_KOD, MUHFIS.SIRA) AS AYSIRA,
MUHFIS.SIRA, MUHFIS.FISNO, NULL ,
(CASE WHEN CEKSENDEK.DEKONT_PRGNO IN (3,6, 10, 35, 36, 45, 46, 49) THEN 'Banka' ELSE '' END ) S_YEDEK1,
AY_KODU,
MUHFIS.SUBE_KODU,
(' NULL ') KAYNAKDOVKUR
FROM MUHFIS WITH (NOLOCK)
LEFT OUTER JOIN (
SELECT DEKOTRA.SERI_NO, DEKOTRA.DEKONT_NO, DEKOTRA.TARIH, MAX(DEKOTRA.FISNO) FISNO, DEKOTRA.ENTEGREFKEY
,MAX(DEKOTRA.ODEME_TURU) ODEME_TURU, MAX(DEKOTRA.BELGE_TIPI) BELGE_TIPI
,MAX(DEKOTRA.VALORTRH) VALORTRH, MAX( IsNull(EXPORTREFNO,'')) EXPORTREFNO, MAX( IsNull(EXEXPENSETYPE,0)) EXEXPENSETYPE, MAX( IsNull(ACIKLAMA1,'')) ACIKLAMA1
FROM TBLDEKOTRA DEKOTRA WITH (NOLOCK)
GROUP BY SERI_NO, DEKONT_NO, TARIH, ENTEGREFKEY
) DEKOTRA ON ( ( ( SubString(DEKOTRA.ENTEGREFKEY,1,2) ) = '11' ) AND MUHFIS.ENTEGREFKEY = DEKOTRA.ENTEGREFKEY)
INNER JOIN CEKSENDEK ON ( CEKSENDEK.SUBE_KODU = LTRIM(RTRIM( SUBSTRING(MUHFIS.ENTEGREFKEY,4,5) )) AND CEKSENDEK.SERI_NO = LTRIM(RTRIM( SUBSTRING(MUHFIS.ENTEGREFKEY,9,2) )) AND CEKSENDEK.DEKONT_NO = SUBSTRING(SUBSTRING(MUHFIS.ENTEGREFKEY,11,8), PATINDEX('%[^0]%',SUBSTRING(MUHFIS.ENTEGREFKEY,11,8)),(8- PATINDEX('%[^0]%',SUBSTRING(MUHFIS.ENTEGREFKEY,11,8)))+1 ) AND SC_NO = SUBSTRING(MUHFIS.ENTEGREFKEY,19,15)) WHERE AY_KODU=5
AND (MUHFIS.TARIH BETWEEN '05/01/2016' AND '05/31/2016')
AND MUHFIS.TUTAR > 0
AND ( (SUBSTRING(MUHFIS.ENTEGREFKEY,1,2) ) = '11' )
AND ( IsNull(DEKOTRA.DEKONT_NO,0) = 0) AND ( (SUBSTRING(MUHFIS.ENTEGREFKEY,3,2) ) <> '41' ) AND NOT ( (CHARINDEX('IADESI ',ACIKLAMA)>0 ) OR ( ( CASE WHEN CHARINDEX(':',RIGHT(MUHFIS.ENTEGREFKEY, 8))>0 THEN CHARINDEX(':',RIGHT(MUHFIS.ENTEGREFKEY, 8),CHARINDEX(':',RIGHT(MUHFIS.ENTEGREFKEY, 8))+1) ELSE 0 END) > 0) ) ORDER BY MUHFIS.TARIH, MUHFIS.FISNO,BA,HES_KOD,SIRA
Conversion failed when converting the varchar value '1100051C' to data type int.(NetsisMS-22018,245)