22,209
社区成员
发帖
与我相关
我的任务
分享
--try
declare @str varchar(8000)
set @str=',A0001,A0002,B0020,C0020,'
select * from tb where charindex(','+fd+',',@str)=0
select * from (select 'A0001' as fd union
select 'A0002' union select'B0020' union select'C0020')t
where fd not in(select fd from tb)
declare @s varchar(1000)
set @s = '"A0001","A0002","B0020","C0020"'
set @s = replace(@s,'","' ,''' as col union all select ''')
set @s = 'select '+replace(@s,'"' ,'''')
set @s = 'select col from ('+@s+'
) a where not exists(select 1 from tb where fd = a.col)'
exec( @s)
select * from (select 'A0001' as fd union
select 'A0002' union select'B0020' union select'C0020')t
where fd not in(select fd from tb)