E defter Hazirlik Çalistirdigimda asagidaki hatayi veriyor. nasil çözebiliriz.
FATURA 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 )
SELECT
(CASE WHEN IsNull(KAPATILMIS,' ') = 'Z' THEN 'Z Raporu'
ELSE
'Fatura'
END ) BELGE_TIPI,
( CASE WHEN IsNull(EFATURA.GIB_FATIRS_NO,' ') = ' ' THEN
(CASE WHEN IsNull(D_YEDEK10, '' ) ='' THEN ''
ELSE
(CASE WHEN IsNull(FATUIRS.GIB_FATIRS_NO,' ') = ' ' THEN FATUIRS.FATIRS_NO
ELSE FATUIRS.GIB_FATIRS_NO END )
END)
ELSE EFATURA.GIB_FATIRS_NO
END ) BELGE_NO,
( CASE WHEN IsNull(D_YEDEK10, '' ) ='' THEN MUHFIS.TARIH
ELSE
(CASE WHEN (D_YEDEK10 = FATUIRS.TARIH) THEN MUHFIS.TARIH
WHEN (FATUIRS.FTIRSIP ='1') THEN D_YEDEK10
WHEN (FATUIRS.FTIRSIP='2') THEN D_YEDEK10
ELSE D_YEDEK10 END )
END ) TARIH,
ROW_NUMBER() OVER (ORDER BY MUHFIS.TARIH, MUHFIS.FISNO,BA,HES_KOD, MUHFIS.SIRA) AS AYSIRA,
MUHFIS.SIRA, MUHFIS.FISNO, NULL ,
(CASE WHEN KS.KRTSOZMASINCKEYNO = 0 THEN 'Nakit'
WHEN KS.KRTSOZMASINCKEYNO >= 1 THEN 'Kredi Karti'
ELSE ''
END ) S_YEDEK1,
AY_KODU,
MUHFIS.SUBE_KODU
FROM MUHFIS WITH (NOLOCK)
INNER JOIN FATUIRS ON (FTIRSIP= CAST( SubString(MUHFIS.ENTEGREFKEY,3,1) AS CHAR(1))
AND FATUIRS.CARI_KODU = LTRIM(RTRIM( SubString(MUHFIS.ENTEGREFKEY,19,15) )) AND FATUIRS.FATIRS_NO= SubString(MUHFIS.ENTEGREFKEY,4,15) )
LEFT OUTER JOIN EFATURA ON (EFATURA.CARI_KODU = FATUIRS.CARI_KODU
AND ( (EFATURA.FATIRS_NO = FATUIRS.GIB_FATIRS_NO) OR (EFATURA.FATIRS_NO = FATUIRS.FATIRS_NO) )
AND ( EFATURA.FTIRSIP = CAST(SUBSTRING(MUHFIS.ENTEGREFKEY,3,1) AS CHAR(1)) ) )
LEFT OUTER JOIN (
SELECT DISTINCT KASA.FISNO KASA_FISNO,KASA.TARIH KASA_TARIH, IsNull(TBLBNKHESSABIT.NETMUHKODU,TBLKASAMAS.MUH_KOD) MUHKOD,ENTEGREFKEY, IsNull(KASA.KRTSOZMASINCKEYNO,0) KRTSOZMASINCKEYNO,TBLKRTSOZMAS.SOZKOD
FROM KASA
LEFT OUTER JOIN TBLKRTSOZMAS WITH (NOLOCK) ON (KASA.KRTSOZMASINCKEYNO=TBLKRTSOZMAS.INCKEYNO)
LEFT OUTER JOIN TBLBNKHESSABIT WITH (NOLOCK) ON (TBLBNKHESSABIT.NETHESKODU=TBLKRTSOZMAS.BANKANETHESKODU)
LEFT OUTER JOIN TBLKASAMAS WITH (NOLOCK) ON (TBLKASAMAS.KSMAS_KOD=KASA.KSMAS_KOD)
WHERE IsNull(GECERLI,'E') = 'E' ) KS
ON (KS.MUHKOD=MUHFIS.HES_KOD AND KS.ENTEGREFKEY=MUHFIS.ENTEGREFKEY
AND ((KS.KRTSOZMASINCKEYNO=0) OR (KS.KRTSOZMASINCKEYNO>0 AND (CHARINDEX(' '+KS.SOZKOD+' ',MUHFIS.ACIKLAMA, 1) > 0 ) ) )
)
WHERE AY_KODU=6
AND (MUHFIS.TARIH BETWEEN '06/01/2016' AND '06/30/2016')
AND MUHFIS.TUTAR > 0
AND ( (SUBSTRING(MUHFIS.ENTEGREFKEY,1,2) ) = '01' )
ORDER BY MUHFIS.TARIH, MUHFIS.FISNO,BA,HES_KOD, MUHFIS.SIRA
Cannot insert duplicate key row in object 'dbo.##TMPEDEFTER' with unique index '##TMPEDEFTER_IND_1'.(NetsisMS-23000,2601)
The statement has been terminated.(NetsisMS-01000,3621)