【发布时间】:2014-11-04 22:00:58
【问题描述】:
我最近得到了这个存储过程,它使用了一个名为@marketCode 的变量。应用程序正在为此变量传递 South 或 null。
在我的选择语句中,如果应用程序通过 null,我想检索除 South 以外的所有市场。
and marketCode =! 'South'
如果应用程序传递了一个非空值,那么我将使用那个值。
and marketCode = 'North'
如何将这两个合并为一个案例?
AND marketCode = (case @marketCode when null then <..not equal to 'South'..>
else <..equal to 'South'..> end )
【问题讨论】: