IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[order_48_105_search]') AND type = 'P')
DROP PROCEDURE [dbo].[order_48_105_search]
GO

-- 生成时间:2018-05-28 18:55:10 by ebs-core  
CREATE  procedure order_48_105_search(
@ordid bigint,
@key nvarchar(200),
@pagesize int 
) 
as  
begin  
set nocount on 
-- 将@key 分解为三个值
declare @key1 nvarchar(200)
declare @key2 nvarchar(200)
declare @key3 nvarchar(200)
set @key1=''
set @key2=''
set @key3=''
declare @i int 
set @key1 = @key 
set @key1 = replace(@key1,'  ',' ') 
set @key1 = replace(@key1,'  ',' ') 
set @key1 = replace(@key1,'  ',' ') 
set @key1 = replace(@key1,',,',',') 
set @key1 = replace(@key1,',,',',') 
set @key1 = replace(@key1,',,',',') 
set @key1 = replace(@key1,',',' ') 
set @key1 = replace(@key1,'  ',' ') 
set @key1 = replace(@key1,'  ',' ') 
set @i = charindex(' ',@key1) 
if (@i>0) 
begin
set @key2 = substring(@key1,@i+1,200) 
set @key1 = substring(@key1,1,@i-1) 
end 
if (@key2>'') 
begin
set @i = charindex(' ',@key2) 
if (@i>0) 
begin
set @key3 = substring(@key2,@i+1,200) 
set @key2 = substring(@key2,1,@i-1) 
end 
end 
if (@key1='') set @key1='%' 
if (charindex('%',@key1)<=0) set @key1='%'+@key1+'%'

if (@key2='') set @key2='%' 
if (charindex('%',@key2)<=0) set @key2='%'+@key2+'%'

if (@key3='') set @key3='%' 
if (charindex('%',@key3)<=0) set @key3='%'+@key3+'%'

select top(@pagesize) * from order_48_105  
where ord2_ordid=@ordid and ( (ord2_bmqk like @key1 and ord2_bmqk like @key2 and ord2_bmqk like @key3) or  (ord2_bz like @key1 and ord2_bz like @key2 and ord2_bz like @key3) or  (ord2_caption like @key1 and ord2_caption like @key2 and ord2_caption like @key3) or  (ord2_code like @key1 and ord2_code like @key2 and ord2_code like @key3) or  (convert(varchar(100),ord2_date, 21) like @key1 and convert(varchar(100),ord2_date, 21) like @key2 and convert(varchar(100),ord2_date, 21) like @key3) or  (ord2_group like @key1 and ord2_group like @key2 and ord2_group like @key3) or  (ord2_ksfs like @key1 and ord2_ksfs like @key2 and ord2_ksfs like @key3) or  (ord2_llfs like @key1 and ord2_llfs like @key2 and ord2_llfs like @key3) or  (ord2_lxdh like @key1 and ord2_lxdh like @key2 and ord2_lxdh like @key3) or  (ord2_mdlx like @key1 and ord2_mdlx like @key2 and ord2_mdlx like @key3) or  (ord2_mdmc like @key1 and ord2_mdmc like @key2 and ord2_mdmc like @key3) or  (ord2_order like @key1 and ord2_order like @key2 and ord2_order like @key3) or  (ord2_pxcuid like @key1 and ord2_pxcuid like @key2 and ord2_pxcuid like @key3) or  (ord2_pxid like @key1 and ord2_pxid like @key2 and ord2_pxid like @key3) or  (ord2_pxjg like @key1 and ord2_pxjg like @key2 and ord2_pxjg like @key3) or  (ord2_qdxq like @key1 and ord2_qdxq like @key2 and ord2_qdxq like @key3) or  (ord2_scfs like @key1 and ord2_scfs like @key2 and ord2_scfs like @key3) or  (ord2_sfbm like @key1 and ord2_sfbm like @key2 and ord2_sfbm like @key3) or  (ord2_sfz like @key1 and ord2_sfz like @key2 and ord2_sfz like @key3) or  (ord2_sfzs like @key1 and ord2_sfzs like @key2 and ord2_sfzs like @key3) or  (ord2_sqdcs like @key1 and ord2_sqdcs like @key2 and ord2_sqdcs like @key3) or  (ord2_sspq like @key1 and ord2_sspq like @key2 and ord2_sspq like @key3) or  (ord2_status like @key1 and ord2_status like @key2 and ord2_status like @key3) or  (convert(varchar(100),ord2_updated, 21) like @key1 and convert(varchar(100),ord2_updated, 21) like @key2 and convert(varchar(100),ord2_updated, 21) like @key3) or  (ord2_xm like @key1 and ord2_xm like @key2 and ord2_xm like @key3) or  (ord2_ygbh like @key1 and ord2_ygbh like @key2 and ord2_ygbh like @key3) or  (ord2_yqdcs like @key1 and ord2_yqdcs like @key2 and ord2_yqdcs like @key3) or  (ord2_zhpfs like @key1 and ord2_zhpfs like @key2 and ord2_zhpfs like @key3) or  (ord2_zj like @key1 and ord2_zj like @key2 and ord2_zj like @key3)) order by ord2_order, ord2_id 
select ord2_id  as ord2id_page from order_48_105 
where ord2_ordid=@ordid and ( (ord2_bmqk like @key1 and ord2_bmqk like @key2 and ord2_bmqk like @key3) or  (ord2_bz like @key1 and ord2_bz like @key2 and ord2_bz like @key3) or  (ord2_caption like @key1 and ord2_caption like @key2 and ord2_caption like @key3) or  (ord2_code like @key1 and ord2_code like @key2 and ord2_code like @key3) or  (convert(varchar(100),ord2_date, 21) like @key1 and convert(varchar(100),ord2_date, 21) like @key2 and convert(varchar(100),ord2_date, 21) like @key3) or  (ord2_group like @key1 and ord2_group like @key2 and ord2_group like @key3) or  (ord2_ksfs like @key1 and ord2_ksfs like @key2 and ord2_ksfs like @key3) or  (ord2_llfs like @key1 and ord2_llfs like @key2 and ord2_llfs like @key3) or  (ord2_lxdh like @key1 and ord2_lxdh like @key2 and ord2_lxdh like @key3) or  (ord2_mdlx like @key1 and ord2_mdlx like @key2 and ord2_mdlx like @key3) or  (ord2_mdmc like @key1 and ord2_mdmc like @key2 and ord2_mdmc like @key3) or  (ord2_order like @key1 and ord2_order like @key2 and ord2_order like @key3) or  (ord2_pxcuid like @key1 and ord2_pxcuid like @key2 and ord2_pxcuid like @key3) or  (ord2_pxid like @key1 and ord2_pxid like @key2 and ord2_pxid like @key3) or  (ord2_pxjg like @key1 and ord2_pxjg like @key2 and ord2_pxjg like @key3) or  (ord2_qdxq like @key1 and ord2_qdxq like @key2 and ord2_qdxq like @key3) or  (ord2_scfs like @key1 and ord2_scfs like @key2 and ord2_scfs like @key3) or  (ord2_sfbm like @key1 and ord2_sfbm like @key2 and ord2_sfbm like @key3) or  (ord2_sfz like @key1 and ord2_sfz like @key2 and ord2_sfz like @key3) or  (ord2_sfzs like @key1 and ord2_sfzs like @key2 and ord2_sfzs like @key3) or  (ord2_sqdcs like @key1 and ord2_sqdcs like @key2 and ord2_sqdcs like @key3) or  (ord2_sspq like @key1 and ord2_sspq like @key2 and ord2_sspq like @key3) or  (ord2_status like @key1 and ord2_status like @key2 and ord2_status like @key3) or  (convert(varchar(100),ord2_updated, 21) like @key1 and convert(varchar(100),ord2_updated, 21) like @key2 and convert(varchar(100),ord2_updated, 21) like @key3) or  (ord2_xm like @key1 and ord2_xm like @key2 and ord2_xm like @key3) or  (ord2_ygbh like @key1 and ord2_ygbh like @key2 and ord2_ygbh like @key3) or  (ord2_yqdcs like @key1 and ord2_yqdcs like @key2 and ord2_yqdcs like @key3) or  (ord2_zhpfs like @key1 and ord2_zhpfs like @key2 and ord2_zhpfs like @key3) or  (ord2_zj like @key1 and ord2_zj like @key2 and ord2_zj like @key3)) order by ord2_order, ord2_id 

set nocount off
end