0819lsl

sql 存储过程参数为空则不作为条件

select DocDetailedNo,CombinedCode,a.ProjectName,DocOperCode,a.PatientID,a.CreateTime,a.ExecutiveDepName ,a.ExecutiveDepNo ,
from ApplyInfo a
left join ApplyAfterDealInfo ap on a.DocDetailedNo=ap.AppFormNo
where 1=1
and a.DocOperCode<>\'CA\'
and a.ExecutiveDepNo = @DepNo
and ap.StudyStatus<>\'3\'
and ap.StudyStatus<>\'2\'
and Convert(char(10),a.CreateTime,120) between @time and @timeEnd
and (a.PatientID in(@Backup2) OR @Backup2=\'\')

以上这种写法可不需要拼接字符串方式 动态处理参数值为空时不作为 筛选条件

分类:

技术点:

相关文章:

  • 2022-02-12
  • 2022-01-10
  • 2022-12-23
  • 2021-11-20
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
  • 2022-12-23
  • 2021-04-15
相关资源
相似解决方案