Link to home
Create AccountLog in
Avatar of Giftcard
Giftcard

asked on

How can i display the name of the folder from a field in a table

How can i display the name of the folder from a field in a table.

Right now i have a field like this, which is a combination of path and file name: /folder/folder1/folder2/12345-ABCD.txt

I want to show this section into a new field in a table: /folder2/
ASKER CERTIFIED SOLUTION
Avatar of Hammo777
Hammo777

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Giftcard
Giftcard

ASKER

Hammo, That Works. I found other way of solving this.

declare @q varchar(100)
declare @p varchar(100)

set @q = '/folder/folder1/folder2/12345-ABCD.txt'
set @p = substring( REVERSE(@q), charindex('/',REVERSE(@q))+1 , LEN(REVERSE(@q)))

select reverse(SUBSTRING( @p, 1, CHARINDEX('/', @p)-1))

Thanks!