SQL SERVER – Getting the second occurrence from charindex function

I need to get the second occurrence of the space for below text. It should be the space after the 56

select charindex(‘ ‘, ‘Posted/edited: 56 days ago’, 2)


The solution would be:

Select charindex(‘ ‘,’Posted/edited: 56 days ago’,(charindex(‘ ‘, ‘Posted/edited: 56 days ago’) +1))

Leave a comment