ALTER PROCEDURE [dbo].[get_goods_search]
@sang varchar(20),
@userIP varchar(20)
AS
set nocount on
declare @sql varchar(5000)
SET @sang=replace(@sang,' ','')
insert SearchHit(searchS,userIP) values (left(@sang,25), @userIP)
if len(@sang)>=2 BEGIN
set @sql = 'select sang_name,brand,code,ea_danga,box_danga,box_su,simage, icon, (case when Convert(varchar(10),indate,112)>=Convert(varchar(10),getdate()-30,112) then 1 else 0 end) as New_icon from goods where hidden_flag=''0'' and ((brand>0 and brand<1000) or brand=20) and '
set @sql = @sql + ' (replace(sang_name,'+char(39) + ' ' + char(39) + ','+char(39)+char(39)+') like ' + char(39) + '%' + @sang + '%' + char(39) + ' or replace(keyword,'+char(39) + ' ' + char(39) + ','+char(39)+char(39)+') like ' + char(39) + '%' + @sang + '%' + char(39) + ' or goods_code like ' + char(39) + '%' + @sang + '%' + char(39) +') or Convert(varchar(7),code)=' + char(39) + @sang + char(39) + ' Order by seq, Code Desc'
END
set nocount off
--select @sql
exec(@sql)