当前位置: 代码迷 >> Sql Server >> 急求一获取特殊段字符的写法。解决办法
  详细解决方案

急求一获取特殊段字符的写法。解决办法

热度:64   发布时间:2016-04-27 15:32:58.0
急求一获取特殊段字符的写法。。
declare   @aa   varchar(60)
select   @aa   = '15http:/22.kf.com/5/0.p33.wma171 '
--这是我自己写的,错误的:   select   left(@lastipto,len(@lastipto)-charindex( '/ ',reverse(@lastipto)))
我要的结果是:0.p33.wma171

我就是要求aa变量中最后一次出现 "/ "后面的所有字符。。

急,,请各位帮忙。。。


------解决方案--------------------
declare @aa varchar(60)
select @aa = '15http:/22.kf.com/5/0.p33.wma171 '
select reverse(left(reverse(@aa), charindex( '/ ', reverse(@aa))-1))

------解决方案--------------------
declare @aa varchar(60)
select @aa = '15http:/22.kf.com/5/0.p33.wma171 '

select right(@aa,charindex( '/ ',reverse(@aa))-1)
------解决方案--------------------
declare @lastipto varchar(60)
select @lastipto = '15http:/22.kf.com/5/0.p33.wma171 '

select right(@lastipto,charindex( '/ ',reverse(@lastipto))-1)

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



declare @aa varchar(60)
select @aa = '15http:/22.kf.com/5/0.p33.wma171 '

print RIGHT(@aa,charindex( '/ ',REVERSE(@aa))-1)
  相关解决方案