日期:2014-05-17 浏览次数:20547 次
select * from tb where cast(substring(fp,3,len(fp)) as int)>=3
and cast(substring(fp,3,len(fp)) as int)<=7
order by cast(substring(fp,3,len(fp)) as int)
use Tempdb
go
--> -->
declare @FPnm table([FP] nvarchar(6))
Insert @FPnm
select N'AP001' union all
select N'AP002' union all
select N'AP003' union all
select N'AP004' union all
select N'AP005' union all
select N'AP006' union all
select N'AP007' union all
select N'AP008' union all
select N'AP0051' union all
select N'AP0052' union all
select N'AP0060'
Select * from @FPnm where cast(stuff([FP],1,2,'') as int) between 3 and 7
/*
FP
AP003
AP004
AP005
AP006
AP007
*/
select * from FPnm where FP >='AP003' and FP <='AP007' and LEN(fp)<=5 order by fp
select * from FPnm where convert(int,right(FP,3))>=3 and convert(int,right(FP,3))<=7