开发者

T-SQL String manipulation

in my DB I have a column given paths like :

  • \myserver\mydir1\dir2\Atest.txt
  • \myserver\mydir1\dir2\Btest.txt

At the end I should update a column with the first character after the last "\" delimiter , therefore "A" and "B" in this example. How can 开发者_高级运维I get this?

Thanks a lot Largo


select substring(YourColumn, len(YourColumn)-charindex('\', reverse(YourColumn))+2, 1)
from YourTable

You have not specified what DBMS you are using. To make this work you need to have these functions available or something similar.

  • substring
  • len
  • charindex
  • reverse
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜