--我自己随意写写的,LZ瞅瞅--> 测试数据: [tb] if object_id('[tb]') is not null drop table [tb] create table [tb] (col numeric(5,4)) insert into [tb] select 0.2500 union all select 0.5000 union all select 1.0000 union all select 2.0000--开始查询 select left(col,len(col)+1-patindex('%[^0.]%',reverse(CONVERT(varchar(100),col)))) from tb--结束查询 drop table [tb]/* ----------------------------------------- 0.25 0.5 1 2(4 行受影响)
--我自己随意写写的,LZ瞅瞅--> 测试数据: [tb]
if object_id('[tb]') is not null drop table [tb]
create table [tb] (col numeric(5,4))
insert into [tb]
select 0.2500 union all
select 0.5000 union all
select 1.0000 union all
select 2.0000--开始查询
select left(col,len(col)+1-patindex('%[^0.]%',reverse(CONVERT(varchar(100),col)))) from tb--结束查询
drop table [tb]/*
-----------------------------------------
0.25
0.5
1
2(4 行受影响)