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, ','))
No comments:
Post a Comment