Skip to content

Instantly share code, notes, and snippets.

@waquwex
Created February 26, 2024 21:14
Show Gist options
  • Select an option

  • Save waquwex/e33816b978a2f9631e76996b694ff7cc to your computer and use it in GitHub Desktop.

Select an option

Save waquwex/e33816b978a2f9631e76996b694ff7cc to your computer and use it in GitHub Desktop.
T-SQL Get Word Count of Text Column (STRING_SPLIT)
SELECT
id,
name,
COUNT(value) AS WordCount
FROM
Peoples
CROSS APPLY
STRING_SPLIT(name, ' ')
GROUP BY
id, name
ORDER BY
WordCount desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment