Count the Occurrence of a Phrase or Word in a Column

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.



Share
  • Facebook
  • Google Bookmarks
  • Ask
  • LinkedIn
  • Socialogs
  • Wikio
  • Digg
  • Twitter
  • SlashDot
  • Reddit
  • MySpace
  • Del.icio.us
  • Blogter
  • BlogMemes
  • Yahoo Buzz






Count the Occurrence of a Phrase or Word in a Column | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.


Gold Coast Aquarium Maintenance | Gold Coast Marine Fish | Gold Coast Tropical Fish
Jewel Jones - Counselling Service - Penrith, Richmond
 
     
 Copyright © 2017 Julian Kuiters
 All trademarks and copyrights on this page are owned by their respective owners.