June 3, 2008 at 4:36 am
Hi guys/girls,
I have a UNC path that I need to pull back the last value of a backslash e.g.
\\value1\value2\value3
I need to store value3 in a variable. I need to read the whole string in and then look for the value after the last occurrence of the \
Any help please?
June 3, 2008 at 4:55 am
Wayne Atherton (6/3/2008)
Hi guys/girls,I have a UNC path that I need to pull back the last value of a backslash e.g.
\\value1\value2\value3
I need to store value3 in a variable. I need to read the whole string in and then look for the value after the last occurrence of the
Any help please?
One solution is:
DECLARE @x NVARCHAR(255)
SET @x = N'\\value1\value2\value3'
DECLARE @l INT
SET @l = CHARINDEX('\', REVERSE(@x))
SELECT SUBSTRING(@x, LEN(@x) - @l+2, @l)
Regards,
Andras
June 3, 2008 at 6:49 am
great stuff - thanks worked a treat.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply