1

I have delimited string like this 'test1:test2:test3:test4:test5'.

I need to get the third and forth values one value at a time. The string always has five values.

0

1 Answer 1

0

You can take a SUBSTRING of your string to ignore the first element, then use PARSENAME. Then, you don't have to use a function.

declare @var varchar(64) = 'test1:test2:test3:test4:test5'

select 
    ThirdElement = parsename(replace(substring(@var,charindex(':',@var) + 1,len(@var)),':','.'),3)
    ,FourthElement = parsename(replace(substring(@var,charindex(':',@var) + 1,len(@var)),':','.'),2)
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.