Showing posts with label String_Split. Show all posts
Showing posts with label String_Split. Show all posts

Wednesday, August 19, 2020

Word Count in SQL Server - String_Split Usage

STRING_SPLIT is a table-valued function that splits the words from the input text and returns into rows. This function has been introduced in SQL Server 2016.

String_split will help in many ways.

1) You can get the word count from the given text.

2) You can pass the string values to a query.


Word Count in SQL

SELECT COUNT(value) 
FROM 
    STRING_SPLIT('This is just a text taken from the most popular book', ' ')


String_Split in Queries to provide multiple values in where clause.

DECLARE @EmpIDs NVARCHAR(100) = '7369,7499,7521'
SELECT Ename
FROM   Emp
WHERE  Empno IN (SELECT value FROM STRING_SPLIT(@EmpIDs, ','))



If you are looking for a word-count program using HiveQL, then click here.
If you are looking for a word-count program using Pig, then click here.

Big Data & SQL

Hi Everybody, Please do visit my new blog that has much more information about Big Data and SQL. The site covers big data and almost all the...