Finding Word Count in Sentence in SQL Server

Hello everyone,

In this article, I will give information about finding the number of words in a sentence in SQL Server.

In SQL Server, in some cases, we may want to find the number of words in the sentence.

You can easily do this with the help of the codes below.

SET @sentence = N'Yavuz Selim Kart is the founder of SQL Server Trainings site and channel.';
       LEN(@sentence) - LEN(REPLACE(@sentence, ' ', '')) + 1 AS WordCount;

When you run the code, you will see a result like the one below.

Finding Word Count in Sentence in SQL Server

As can be seen, the number of words has been calculated.

Good luck to everyone in business and life.


Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!