Using CASE in WHERE Statement when parameter has multiple values

后端 未结 3 1979
北海茫月
北海茫月 2021-01-24 00:07

I have a problem which I think relates to having a multiple value parameter.

In my TblActivity there are two fields TblActivity.ActivityServActId

3条回答
  •  时光说笑
    2021-01-24 00:49

    So after a lot of messing around I put together a simple workaround for this by dropping my use of CASE altogether - but I have a suspicion that this is not a terribly efficient way of doing things.

    WHERE
    (@YESNOActivity = 'No' OR (@YESNOActivity = 'Yes' AND
    TblActivity.ActivityServActId IN (@ServiceActivity)))
    
    AND
    
    (@YESNOContract = 'No' OR (@YESNOContract = 'Yes' AND
    TblActivity.ActivityContractId IN (@Contract)))
    

提交回复
热议问题