I have the following string:
bzip2,1,668,sometext,foo,bar
How can I SELECT only sometext,foo,bar
? The length of the string preceding the 3rd comma may differ and there may be commas within sometext,foo,bar
.
I'd like this in as concise code as possible, i.e. preferably 1 line of code, no loops. But feel free to post any solution you think of.
I just figured out something that works:
try this:
Do a substring from 3rd comma to the end of the string.. To find the 3 commas , I am using charindex() function 3 times
result:
Code:
Output:
Edit
Added nullif's to the third comma calculation part, without them it's possible to get inconsistent results.
Here is another idea
Result