How to count number of words in column using sql server - Free Asp.Net,MVC,AngularJs,Jquery,Javascript,Sql Server,WCF,Entity framework snippets and tutorial

How to count number of words in column using sql server

In this article I am going to explain how to count number of words in column using sql server.


Implementation:

I want to count the number of words in a column. Run the below given query to get total number of words: 

DECLARE @words VARCHAR(250)
SET @words = 'article mirror, asp.net, sql server'

SELECT LEN(@words) - LEN(REPLACE(@words, ' ', '')) + 1 as 'total number of words'

Result:

S.No.
Total number of words
1
5




What do you think about this article?

If you found this article useful, please share and follow on Facebook, Twitter, Google Plus and other social media websites. To get free updates subscribe to newsletter. Please put your thoughts and feedback in comments section.

Share this

Share on FacebookTweet on TwitterPlus on Google+


EmoticonEmoticon