当前位置: 代码迷 >> Sql Server >> SQL语句截取字符解决思路
  详细解决方案

SQL语句截取字符解决思路

热度:102   发布时间:2016-04-24 18:52:48.0
SQL语句截取字符
如例:

ID              Address                              

1               0.1四川
2               0.2四川xxxxx
3               0.3四川yyyyyyyy
4               0.4四川xxxxxxxxxx

我需要的结果如下

ID              Address                              

1               四川
2               四川xxxxx
3               四川yyyyyyyy
4               四川xxxxxxxxxx

求SQL一条

------解决方案--------------------

select 1 ID, N'0.1四川' Address
into #t
union all select 2, N'0.2四川xxxxx'
union all select 3, N'0.3四川yyyyyyyy'
union all select 4, N'0.4四川xxxxxxxxxx'

select id,SUBSTRING(Address, PATINDEX('%[^0-9.]%',Address),LEN(Address)- PATINDEX('%[^0-9.]%',Address)+1) Address
from #t;
  相关解决方案