假设我有一个存储过程,其中我将 5 个过滤器作为参数传递。这些参数是我查询中每一列的过滤器。我的查询有 5 个字段。如果我的过滤器有 1 个或多个 NULL(或 '')值参数,防止我的查询引发异常/错误的最佳方法是什么?
SELECT
[helpings_turkey],
[helpings_green_beans],
[scoops_squash],
[qty_buscuits],
[pieces_pie]
FROM
[thanksgiving_guest]
WHERE
[helpings_turkey] > @helpings_turkey_filter
AND [helpings_green_beans] > @helpings_green_beans_filter
AND [scoops_squash] > @scoops_squash_filter
AND [qty_buscuits] > @qty_buscuits_filter
AND [pieces_pie] > @pieces_pie_filter