Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

problema de consulta sql ao relatar


Se o seu parâmetro @ged for igual ao que diz em seu comentário, por que não abandonar a abordagem de string sql e usar:

EDITAR para parâmetros extras
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

Como alternativa, você pode tentar usar exec sp_executesql .