sql >> Base de Datos >  >> RDS >> Sqlserver

problema de consulta sql al informar

Si su parámetro @ged es igual a lo que dice en su comentario, entonces ¿por qué no abandonar el enfoque de cadena sql y usar:

EDITAR para parámetros adicionales

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

Alternativamente, puede intentar usar exec sp_executesql .