作成存储过程参数create proc @s varchar(100) as exec ('select .... where detail not in('+@s+')')
写一个临时表 放入条件参数where detail not in (select xxx from 临时表)
declare @S varchar(4000) set @S=111,222,33 --如果你是这样传的话 exec ('select * from [table] where detail not in('''+replace(@S,',',''',''')+''')')
declare @SQL varchar(8000) declare @a varchar(20) declare @b varchar(20)set @a='误工费' set @b='加急费' set @SQL='... where detail not in ('''+@a+''','''+@b+'''' exec(@SQL)
将数目不定的参数转成 aas,dff,ddd 的形式 用一个参数@a处理 where charindex(','+rtrim(detail)+',' , ','+@a+',')>0 如果有前台直接在前台生成not in ('aas','dff','ddd')语句即可
as
exec ('select .... where detail not in('+@s+')')
放入条件参数where detail not in (select xxx from 临时表)
set @S=111,222,33 --如果你是这样传的话
exec ('select * from [table] where detail not in('''+replace(@S,',',''',''')+''')')
declare @a varchar(20)
declare @b varchar(20)set @a='误工费'
set @b='加急费'
set @SQL='... where detail not in ('''+@a+''','''+@b+''''
exec(@SQL)
where charindex(','+rtrim(detail)+',' , ','+@a+',')>0
如果有前台直接在前台生成not in ('aas','dff','ddd')语句即可
where charindex( ', '+rtrim(detail)+ ', ' , ', '+@a+ ', ')> 0
--------------------------------------------------------------------------
好办法,不知性能如何。