In
this article I am going to explain how to count number of words and character
using sql server.
In
previous article I have explained how to set auto incremented, auto generatedalphanumeric unique ID in sql server, how to combine 2 or more columns into onecolumn in SQL server and show and hide on dropdown selection using Jquery .
Implementation:
Sql
server query to count words:
DECLARE @words VARCHAR(250)
SET @words = 'asp.net, sql server'
SELECT LEN(@words) - LEN(REPLACE(@words, ' ', '')) + 1 as 'number of words'
Result:
S.No.
|
number of words
|
1
|
3
|
Sql
server query to count number of occurrence:
E.g.
I want to count the occurrence of word ‘e’.
Declare @character varchar(100)
Set @character = 'sql server, asp.net'
Select Len(@character) - Len(Replace(@character, 'e', '')) as 'number of occurrence'
Result:
S.No.
|
Number of occurrence
|
1
|
3
|
0 Comments