T-SQL Where Clause Case Statement Optimization (optional parameters to StoredProc)

后端 未结 5 1020
死守一世寂寞
死守一世寂寞 2021-02-05 11:19

I\'ve been battling this one for a while now. I have a stored proc that takes in 3 parameters that are used to filter. If a specific value is passed in, I want to filter on that

5条回答
  •  猫巷女王i
    2021-02-05 11:53

    No other way I can think of then doing:

    WHERE

    (MyCase IS NULL OR MyCase = @MyCaseParameter) AND ....

    The second one is more simpler and readable to ther developers if you ask me.

提交回复
热议问题