Finding Word Count in Sentence in SQL Server
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.
DECLARE @sentence NVARCHAR(MAX); SET @sentence = N'Yavuz Selim Kart is the founder of SQL Server Trainings site and channel.'; SELECT TOP 1 LEN(@sentence) - LEN(REPLACE(@sentence, ' ', '')) + 1 AS WordCount;
When you run the code, you will see a result like the one below.
As can be seen, the number of words has been calculated.
Good luck to everyone in business and life.