且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

传入值为空时使用可选参数?

更新时间:2023-11-30 23:12:28

更好的解决方案,感谢 pmbAustin

Better solution, thanks to pmbAustin

@exclude_new_1 = COALESCE(@exclude1, '');

旧答案:

使用 case 语句设置新参数

Set new parameters with case statement

@exclude_new_1 = CASE WHEN (@exclude1 IS NULL) THEN '' ELSE @exclude1 END

在您的选择中使用新参数.应该做这份工作...

use the new parameters in your select. Should do the job...