Using SQL I’d like to return all text before the 3rd forward slash in a column
so
/one/two/three/whatever/testing
would return:
/one/two/three
Any quick and dirty way to do this in SQL (specifically MS T-SQL under MS SQL 2005+) ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since you said “quick and dirty”, I’m assuming that this very quick and very dirty solution won’t receive a bunch of down votes. The SQL below uses multiple
SUBSTRING()functions to find the third slash:You can see a working example here.