Count of words in column
Input Data:
Output Data:
DECLARE
@WordCount TABLE
(
[Word
List] varchar(100)
)
INSERT INTO @WordCount
VALUES
('Adam Michelle Larry'),('Pisa London Moscow Delhi'),
('Maths Physics'),('England'),('a b c d e f g h')
SELECT * FROM @WordCount
SELECT [Word List],LEN([Word List]) - LEN(REPLACE([Word List], ' ', '')) + 1 AS [Count] FROM @WordCount
Nice information, thanks for sharing
ReplyDelete