I have the following string:
bzip2,1,668,sometext,foo,bar
How can I SELECT only sometext,foo,bar
? The length of the string pre
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
declare @str varchar(50)='bzip2,1,668,some,text'
select substring(@str,
CHARINDEX(',',@str,CHARINDEX(',',@str,CHARINDEX(',',@str,1)+1)+1)+1,
LEN(@str)-CHARINDEX(',',@str,CHARINDEX(',',@str,CHARINDEX(',',@str,1)+1)+1))
result:
some,text