存储过程中select where条件后如果条件关联变量则可以使用如下代码,变量允许为空,当为空时则不会执行筛选条件
Select Distinct TR.int_id, TR.vch_pmd from table_r TR inner join TABLE_PPT on TPPT.int_id = TR.int_id where (TPPT.vch_s_code = @in_Code or len(isnull(@in_Code, '')) = 0)
存储过程中select where条件后如果条件关联变量则可以使用如下代码,变量允许为空,当为空时则不会执行筛选条件
Select Distinct TR.int_id, TR.vch_pmd from table_r TR inner join TABLE_PPT on TPPT.int_id = TR.int_id where (TPPT.vch_s_code = @in_Code or len(isnull(@in_Code, '')) = 0)
转载于:https://www.cnblogs.com/Aaron-Lee/p/7094484.html