Ignoring a NULL parameter in T-SQL

后端 未结 10 934
余生分开走
余生分开走 2020-12-03 01:40

I want to be able to pass in a list of parameters, and ignore the ones which are NULL. So that the query is in effect pretending that the filter isn\'t there and ignoring it

10条回答
  •  無奈伤痛
    2020-12-03 01:49

    Look at the following link in the section titled "The Case Study: Searching Orders". This explores all options in depth and should give you an excellent overview of the costs associated with each of these options. Warning, be very careful when using COALESCE it may not return what you think it is.

    Regards,

    Tim

提交回复
热议问题