Hi there..
This is my query... but it returns incorrect syntax near '+'
DECLARE @refKlinik_id INT
SET @refKlinik_id = 24
DECLARE @kriter VARCHAR(50)
IF @refKlinik_id <=0
BEGIN
SET @kriter = ''
END
ELSE
SET @Kriter = 'AND H.refKlinik_id =' + @refKlinik_id
SELECT H.adi + ' ' + H.soyadi AS Hasta, H.tcKimlikNo, CONVERT(varchar, H.dogumTarihi, 103) AS DogumTarihi, K.kisaAdi AS Klinik, A.acikAdres + A.ilce + A.il AS Adres,
A.tel1, A.gsm, CASE H.hastaKartiVar WHEN 1 THEN 'Hasta Kartı Sahibi' WHEN 0 THEN 'Hasta Kartı Yok' WHEN NULL
THEN 'Hasta Kartı Yok' END AS HastaKartiDurumu
FROM Hastalar AS H INNER JOIN
Klinikler AS K ON K.klinik_id = H.refKlinik_id INNER JOIN
Adresler AS A ON A.refHasta_id = H.hasta_id
WHERE (K.refKlinikGrup_id = 1) AND (H.durumu = 1) + @kriter + AND (A.aktif = 1)
ORDER BY H.adi