日期:2014-05-18 浏览次数:20632 次
declare @s varchar(50)
select @s='A0000000003,A0000000006'
select
 * 
from
 tb 
where
 串码 between
 left(@x,charindex(',',@s)-1)
and
 substring(@s,charindex(',',@s)+1,20)
------解决方案--------------------
create table t10(ID int,串码 varchar(20))
insert into t10
select 1, 'A0000000001' union all
select 2, 'A0000000002' union all
select 3, 'A0000000003' union all
select 4, 'A0000000004' union all
select 5, 'A0000000005' union all
select 6, 'A0000000006' union all
select 7, 'A0000000007'
-- 程序中输入的串@x
declare @x varchar(50)
select @x='A0000000003,A0000000006'
select * from t10
where 串码 between left(@x,charindex(',',@x)-1)
and substring(@x,charindex(',',@x)+1,20)
ID          串码
----------- --------------------
3           A0000000003
4           A0000000004
5           A0000000005
6           A0000000006
------解决方案--------------------