Search for specific text in comments

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-------------------------------------------------------------------
/*
  NOTE: Search String is case sensitive, but does not have to
    match the whole word.
*/
-------------------------------------------------------------------

DECLARE @SearchString varchar(100) = ##TextToSearchFor:string##;
--TextToSearchFor: Search String "Must be case-sensitive"

IF len(@SearchString) < 3
  SELECT 'Query string too short...' AS Result;
ELSE
  SELECT 
    C.Id AS [Comment Link], 
    C.Text,
    C.CreationDate,
    P.Id AS [Post Link]
  FROM Comments C
    INNER JOIN Posts P
      ON C.PostId = P.Id
  WHERE C.Text LIKE '%' + @SearchString + '%';

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results