Welcome to Julian Kuiters Monday, May 21 2018 @ 07:48 AM AEST

Count the Occurrence of a Phrase or Word in a Column

  • Contributed by:
SQL Server 2000

Simple little bit of code that will show you the number of times the value of @PhraseOrWordToCount is found in TextColumn.

SELECT (LEN(TextColumn) - LEN(REPLACE(TextColumn, @PhraseOrWordToCount, '')) / LEN(@PhraseOrWordToCount)) AS Occurrence
FROM dbo.MyTable

I noticed this on Simon Sabin's blog, I think it has more applications than just FullText searches so I thought I'd do a modified re-post.