22,209
社区成员
发帖
与我相关
我的任务
分享
--> 测试数据: [TB]
if object_id('[TB]') is not null drop table [TB]
create table [TB] (col varchar(7))
insert into [TB]
select 'ABCD01' union all
select 'b00212' union all
select '1213ABc'
select
result=substring(reverse(col),patindex('%[0-9]%',reverse(col)),1)
from [TB]
/*
result
------
1
2
3
(3 行受影响)
*/
drop table tb
select right(字段,1) from tb