TSQL Case in where statement if parameter is null

前端 未结 4 1230
失恋的感觉
失恋的感觉 2021-02-06 01:09

I have a SP that gives me a lot of hard times.

The sp gets a two parameters @madeByUserId and @reportedByUserId. I want to have something like:

 select          


        
4条回答
  •  忘了有多久
    2021-02-06 02:01

    Add an if statement

    IF (@reportedByUserId IS NOT NULL)

    SELECT * FROM table t WHERE t.MadeByUserId = madeByUserId etc

提交回复
热议问题