create table Information (Numbetr varchar(30))insert into Information select '2012年第99号' union all select '2012年第100号' select top 1 Numbetr from Information order by cast(substring(Numbetr, charindex('第',Numbetr)+1, charindex('号',Numbetr)-charindex('第',Numbetr)-1) as int) descNumbetr ------------------------------ 2012年第100号(1 row(s) affected)
select max(convert(int,Numbetr)) from Information
我建议你把2012年第99号这里面的数字都截取出来,转换成int,在比较。
create table Information
(Numbetr varchar(30))insert into Information
select '2012年第99号' union all
select '2012年第100号'
select top 1 Numbetr
from Information
order by
cast(substring(Numbetr,
charindex('第',Numbetr)+1,
charindex('号',Numbetr)-charindex('第',Numbetr)-1)
as int) descNumbetr
------------------------------
2012年第100号(1 row(s) affected)