Given the following string called @ToSearch how would I get the result matching the index of all the S characters in the string. For example:
set @ToSearch = 'SQLServer 2008 includes a variety of string and null functions' ;
set @Tofind = 's';
match 1       match 2   match 3       match 4
----------- ----------- ----------- -----------
1              4              23       38
I tried this but is not working like I suspected.
SET @ToSearchTemp = 
    SUBSTRING(@ToSearchTemp, CHARINDEX('s',@ToSearchTemp,1), LEN(@ToSearchTemp) );
Any ideas how to solve this with CTE or simply with query.
 
     
    