SQL Server: TSQL Script to find Count the number of Occurrences of a String

In this post, I am sharing one TSQL script to find count the number of occurrences of a string in SQL Server.

This is a very basic demonstration, but sometimes it helps a lot to do this kind basic analysis using TSQL.

Sometimes, we find that column like Reasons or Remarks has some duplicate words or strings. As we are using this data for our report’s purpose, so it needs to find the total number of occurrences for that string.
Based on this count, we can perform further operations like: update, delete of that duplicate words.

Below is a small demonstration of this:

First, Create a table with sample data:

Script to find the occurrence of ‘demo’ word:

The Result:

SQL Server String Occurrence

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from dbrnd.com

Sort by:   newest | oldest | most voted

Thank You Bro