0、存储过程开头变量定义
@FBeginDate varchar(10), --单据起始日期 @FEndDate varchar(10), --单据截止日期。 @FItemID varchar(50), @FItemID2 varchar(50), @FCust varchar(50), @FCust2 varchar(50), @FStatus varchar(10) @FType varchar(50), --单据类型 @FBillNo varchar(50), --单据编号
1、日期范围查询
and t.FDate>=@FBeginDate and t.FDate<=case when @FEndDate='' then '2100-01-01' else @FEndDate end
2、客户代码范围查询
and t11.FNumber>=@FCust and t11.FNumber<=case when @FCust2='' then (select MAX(FNumber) from t_Organization) else @FCust2 end
3、物料代码范围查询
and t14.FNumber>=@FItemID and t14.FNumber<=case when @FItemID2='' then (select MAX(FNumber) from t_ICItem) else @FItemID2 end
4、单据类型模糊查询
and isnull(FType,'') like '%'+@FType +'%'