0

我真是一脸懵逼…………

谁能告诉我为什么

   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 函数的长度参数无效。

4

1 回答 1

1

愚蠢的!我在这里找到了解决方案:

由于句号,SQL charindex 抛出传递给 LEFT 或 SUBSTRING 函数的无效长度参数?

对(m.username, charindex('\', REVERSE(m.username) +'\' ) -1) as [OK_Yes]

于 2013-10-07T14:11:13.370 回答