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

后端 未结 5 1377
灰色年华
灰色年华 2021-02-05 10:54

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条回答
  •  灰色年华
    2021-02-05 11:43

    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.

提交回复
热议问题