"SQL query WHERE statement - range query / fuzzy query"

0, stored procedures at the beginning of the variable definition

@FBeginDate varchar (10), - starting date document     
@FEndDate varchar (10), - the document expiration date. 
VARCHAR @FItemID (50),            
@ FItemID2 VARCHAR (50), 
@FCust VARCHAR (50), 
@ FCust2 VARCHAR (50), 
@FStatus VARCHAR (10)   
@FType VARCHAR (50), - document type 
@FBillNo varchar (50 ), --Document Number

 1, the date range queries

and t.FDate>=@FBeginDate
and t.FDate<=case when @FEndDate='' then '2100-01-01' else @FEndDate end

 2, client code range queries

and t11.FNumber>=@FCust
and t11.FNumber<=case when @FCust2='' then (select MAX(FNumber) from t_Organization) else @FCust2 end

 3, the material code range queries

and t14.FNumber>=@FItemID 
and t14.FNumber<=case when @FItemID2='' then (select MAX(FNumber) from t_ICItem) else @FItemID2 end

 4, document type fuzzy query

and isnull(FType,'') like '%'+@FType +'%'

 

Guess you like

Origin www.cnblogs.com/zhugq02/p/11237432.html