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
精彩评论