日期:2014-05-17 浏览次数:20557 次
create table #tb(箱号 varchar(10),毛重 int)
insert into #tb
select '1-10',21
union all select '11-17',30
union all select '18-20',25
declare @v varchar(10)
set @v='12'
select *
from #tb
where @v between left(箱号,charindex('-',箱号)-1)
and right(箱号,len(箱号)-charindex('-',箱号))
drop table #tb
--结果
/*
11-17 30
*/