Ако вашият параметър @ged е равен на това, което пише във вашия коментар, тогава защо не изоставите подхода на sql низ и не използвате:
РЕДАКТИРАНЕ за допълнителни параметри
CREATE proc [dbo].[con]
@J_Sec as nvarchar(255),
@male int,
@age_18_24 int,
@student int,
@main_lmg int,
@main_Price int,
@alt_lmg int,
@alt_price int,
@source_ka INT
as
select
(case
when c.Age_18_24=1 then '18-24'
when c.Age_25_29=1 then '25-29'
when c.Age_30_39=1 then '30-39'
when c.Age_40_Above=1 then '40-above'
else null
end)
AS "Age"
, c.status
from consumer c
inner join dbo.Journey j on c.JOURNEY_SEQUENCE = j.JOURNEY_SEQUENCE
inner join Teams t on j.Team_id = t.Team_id
where
c.journey_sequence= @J_Sec
and male != @male
and Age_18_24 != @age_18_24
and Student != @student
and Main_LMG != @main_lmg
and Main_Price != @main_Price
and ALT_LMG != @alt_lmg
and ALT_Price != @alt_price
and Source_Ka != @source_ka
go
Като алтернатива можете да опитате да използвате exec sp_executesql .