Wednesday, October 26, 2016

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




No comments:

Post a Comment