主要是你前缀有没有规律:如果都是P select * from table where cast(replace(等级,'p','') as decimal(10,2))>30
where 等级 > 'P30'
select * from 表 where cast(right(等级,len(等级)-1) as decimal(4,2)) > 30
create function getint(@ varchar(8000)) returns int as begin while len(@)>0 and isnumeric(@)=0 set @=right(@,len(@)-1) return @ end goselect dbo.getint('af45') go drop function getint
select * from table where cast(replace(等级,'p','') as decimal(10,2))>30
returns int
as
begin
while len(@)>0 and isnumeric(@)=0
set @=right(@,len(@)-1)
return @
end
goselect dbo.getint('af45')
go
drop function getint