UNC Path

  • 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?

  • 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


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • 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