日期:2014-05-16  浏览次数:20503 次

special =left(b.dynaev1,len(b.dynaev1)-charindex('X',reverse(b.dynaev1)))
求大大们解释一下这段
special  =left(b.dynaev1,len(b.dynaev1)-charindex('X',reverse(b.dynaev1)))

是什么意思...
越详细越好,我看不懂= =!
------解决方案--------------------
引用:
Quote: 引用:

reverse是反转函数。将dynaev1反转

CHARINDEX判断反转以后的第一个X的位置

LEN是长度

LEFT截取。



baseunitrate =  convert( int ,right(b.dynaev1,len ( b.dynaev1)- len(left(b.dynaev1,len(b.dynaev1)
-charindex('X',reverse(b.dynaev1)))  )-1))

那这句呢?


给你一个例子;
select baseunitrate =  convert( int ,right(b.dynaev1,len ( b.dynaev1)- len(left(b.dynaev1,len(b.dynaev1)
-charindex('X',reverse(b.dynaev1)))  )-1))
from
(
select '100X100X5'  dynaev1
)b
/*
baseunitrate
5
*/

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

select baseunitrate =  convert( int ,right(b.dynaev1,len ( b.dynaev1)- len(left(b.dynaev1,len(b.dynaev1)
-charindex('X',reverse(b.dynaev1)))  )-1))
from
(
select '100X100X5'  dynaev1
)b
/*
baseunitrate
5
*/

这个代码的意思应该是,找字符串中的最后一个x,之后的数字,提取出来
------解决方案--------------------
你拿个字符串,替换b.dynaev1这个列名,然后逐部分执行一下,体会一下,然后看看联机丛书