DECLARE @TR1 DATETIME, @TR2 DATETIME

SET @TR1= :TARIH1
SET @TR2= :TARIH2

DECLARE @ISLEMTABLO BlnTableType1, @TP NVARCHAR(500)
DELETE FROM @ISLEMTABLO

INSERT INTO @ISLEMTABLO(KODU)
SELECT DISTINCT(ISLEM) FROM TAHODEME
WHERE 100=100 AND 1=1 AND 3=3
AND KODU IN (SELECT KODU FROM CARI WITH (NOLOCK) WHERE 8=8 AND 100=100)
AND TARIH >= @TR1 AND TARIH <= @TR2

SET @TP = (SELECT dbo.Degerleri_Tablodan_Getir( @ISLEMTABLO ))

/*
{100FIRMA_KODU"Firma Kodu"}
{100SUBE_KODU"Şube Kodu"}
{100AKTIF"Aktif Kayıtlar"}

{8CARI.KODU"Cari Kodu"}

{7CINSI"Cari Cinsi"}
{7SEKTOR"Cari Sektör"}
{7GRUBU"Cari Grup"}
{7BOLGE"Cari Bölge"}

{3ISLEM"İşlem Türü"}
{1PROJE"Proje Kodu"}
{1DEPARTMAN"Departman Kodu"}
{1PERSONEL"Personel Kodu"}

*/

SELECT
COUNTER, TARIH, KODU, ISLEM, ESERI, ESIRA, DTURU, DKURU, DTOPLAM,
TLTOPLAM, IDTURU, IDKURU, IDTOPLAM,DEPARTMAN, PERSONEL, MUH_ENT,
(SELECT ADI FROM CARI WHERE CARI.KODU=TAHODEME.KODU) AS CARIADI,
(SELECT ADI FROM PERSONEL WHERE PERSONEL.KODU=TAHODEME.PERSONEL) AS PERSONELADI,
(SELECT ADI FROM DEPARTMAN WHERE DEPARTMAN.KODU=TAHODEME.DEPARTMAN) AS DEPARTMANADI
FROM TAHODEME
where 1=1 AND 100=100 and KODU IN (SELECT KODU FROM CARI WHERE 7=7)
and TARIH>=@TR1
AND TARIH<=@TR2
AND ISLEM IN (Select * from Degerler(@TP))
AND KODU IN (SELECT KODU FROM CARI WITH (NOLOCK) WHERE 8=8 AND 100=100)