0
column1
\\abc\tri\eds\rf1\edr\4ed
\\f.d\tri\ef\poe
\\ghi0j\tri\gf\rf\k\hg\ose

' ' '

i got some rows like that in a column

now i want to get the result set like

\\abc\tri\eds
\\f.d\tri\ef\
\\ghij\tri\gf

simply from first '\' to end of 4th '\'

1 Answer 1

1

In this week's episode of Horrible Code I Have Written For StackOverflow...

SELECT
    SUBSTRING(column1, 1,
        CHARINDEX('\', column1,
            CHARINDEX('\', column1,
                CHARINDEX('\', column1, 3) + 1) + 1))
FROM
    TableName
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.