我真的很困惑......
有人可以告诉我为什么
charindex('\', REVERSE('test\henrov')) as char1,
charindex('\', REVERSE('test\henrov'))-1 as char2,
len(RIGHT('test\henrov', charindex('\', REVERSE('test\henrov'))))-1 as test,
right('test\henrov',6) as [OK],
right('test\henrov', charindex('\', REVERSE('test\henrov'))-1) as [ALSO_OK]
有效,
charindex('\', REVERSE(m.username)) as char1,
charindex('\', REVERSE(m.username))-1 as char2,
len(RIGHT(m.username, charindex('\', REVERSE(m.username))))-1 as test,
right(m.username,6) as [OK],
right(m.username, charindex('\', REVERSE(m.username))-1) as [NOT_OK]
不起作用? m.username是一个包含'test \ henrov'的varchar .....
我收到错误:传递给RIGHT函数的长度参数无效。
答案 0 :(得分:1)
笨!我在这里找到了解决方案:
对(m.username,charindex('\',REVERSE(m.username) +'\')-1)as [OK_Yes]