CASE in WHERE, SQL Server

前端 未结 5 1841
南笙
南笙 2020-12-06 04:47

I\'m doing some search, where users are choosing in dropdown some clauses. When they leave some box empty, I want query to ignore clause. I know CASE, and best I thought of

5条回答
  •  情深已故
    2020-12-06 05:11

    You can simplify to:

    WHERE a.Country = COALESCE(NULLIF(@Country,0), a.Country);
    

提交回复
热议问题