日期:2014-05-17 浏览次数:20453 次
select * from [TABLE] where charindex(',A1,',','+F1+',')>0 and charindex(',ABC,',','+F2+',')>0
------解决方案--------------------
select * from TB where charindex('A1,',F1+',')>0 And Charindex('ABC,',F2+',')>0
------解决方案--------------------
if object_id(N'[t]') is not null drop table [t] go create table t([F1] varchar(10),[F2] varchar(10)) go insert into t select 'A1,BB,C','ABC,CC' union all select 'AA','BC,QQQ' union all select 'A1A','ABCD,ZZ' go declare @f1 varchar(10),@f2 varchar(10) select @f1='A1',@f2='ABC' select * from t where charindex(','+@f1+',',','+[F1]+',')>0 and charindex(','+@f2+',',','+[F2]+',')>0 /* (3 row(s) affected) F1 F2 ---------- ---------- A1,BB,C ABC,CC (1 row(s) affected) */
------解决方案--------------------