• Just adding a solution that goes a little bit further than Don's.

    WITH

    E(n) AS(

    SELECT n FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) E(n) --10 rows

    ),

    E2(n) AS(

    SELECT a.n FROM E a, E b --10 x 10 = 100 rows

    ),

    E4(n) AS(

    SELECT a.n FROM E2 a, E2 b --100 x 100 = 10,000 rows

    ),

    cteTally AS(

    SELECT TOP(len(@inputString) - len(@searchString) + 1) --Limit the number of rows

    ROW_NUMBER() OVER( ORDER BY (SELECT NULL)) i

    FROM E4

    ),

    cteResults AS(

    select

    CAST( count(tt.i) over (partition by null) AS varchar(5)) numberFound ,

    tt.i

    from cteTally tt

    where SUBSTRING(@inputString, tt.i, len(@searchString)) = @searchString

    )

    SELECT Result

    FROM cteResults

    CROSS APPLY( VALUES(1, 'POSITION OF THE SEARCH STRING >> "' + @searchString + '" IS AT : ' + cast(i as varchar(5))),

    (2, 'THE SEARCHED STRING APPEARED >> ' + numberFound + ' TIMES'),

    (3, '**** END OF SEARCH ***') ) cav(roworder, Result)

    GROUP BY Result, roworder

    ORDER BY roworder, MIN(i)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2