ALTER procedure [dbo].[GetProductList]
(@lx varchar(100))
as
declare @sql varchar(1000)
set @sql='select ID,pro_name,picture from product where lx in ('''+@lx+''')'
exec(@sql)@lx 为'中央空调','挂机'
这样就查不出结果
(@lx varchar(100))
as
declare @sql varchar(1000)
set @sql='select ID,pro_name,picture from product where lx in ('''+@lx+''')'
exec(@sql)@lx 为'中央空调','挂机'
这样就查不出结果
(@lx varchar(100))
as
declare @sql varchar(1000)
set @sql='select ID,pro_name,picture from product where lx in ('+@lx+')'
exec(@sql)
try!
改成print (@sql)看看出来的结果
(@lx varchar(100))
as
declare @sql varchar(1000)
set @sql='select ID,pro_name,picture from product where charindex(cast(lx as varchar), '''+@lx+''') > 0'
exec(@sql)
as
begin
declare @sql varchar(1000)
set @lx = ',' + @lx + ','
set @sql='select ID,pro_name,picture from product where charindex('','' + cast(lx as varchar) + '','',''' + @lx + ''') > 0'
exec(@sql)
end
go