Thanks for your message I solved my problem like this
ALTER FUNCTION [VEZNE].[fnMakbuzIslemGetir]
(
@refNo as int
)
RETURNS @tablename TABLE (kontrol1 char(1),key0 numeric(18,0) ,tarih datetime ,hizkod char(12),hizad char(75),ytlhizfiyat decimal(18,2) ,hizmiktar numeric(18,2),ytlhiztutar decimal(18,2))
AS
BEGIN
DECLARE @durum AS VARCHAR
DECLARE @hastaTuru AS VARCHAR
DECLARE @makTipi AS VARCHAR
SET @durum = (SELECT durum FROM TH_RefKart WHERE RefNo = @refNo)
SET @hastaturu = (SELECT HastaTuru FROM TH_Dosya WHERE DosyaNo in (SELECT DosyaNo FROM TH_RefKart WHERE RefNo = @refNo))
SET @makTipi = (SELECT maktipi FROM TH_Islem WHERE refNo = @refNo )
IF ((@hastaTuru = 'Ücretli') AND (@durum = 'AYAKTA')) OR @makTipi = '0'
BEGIN
INSERT @tablename SELECT kontrol1, key0, tarih, hizkod, hizad, ytlhizfiyat, hizmiktar, ytlhiztutar
FROM TH_Islem
WHERE refno= @refNo and DekontNo = '0' and anahtar<> -1
END
RETURN
END
but now I have another problem at this row
SET @makTipi = (SELECT maktipi FROM TH_Islem WHERE refNo = @refNo)
because this SELECT returns multi rows value. what can I do now?