Skip to content

Instantly share code, notes, and snippets.

@ngbrown
Last active July 18, 2019 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngbrown/b8604e10090c7b1ed5ab34d4eb1b03f9 to your computer and use it in GitHub Desktop.
Save ngbrown/b8604e10090c7b1ed5ab34d4eb1b03f9 to your computer and use it in GitHub Desktop.
Check used characters
-- Based on https://stackoverflow.com/a/2926213/25182
WITH a AS (SELECT LTRIM(dut_eosonum) AS s, '' AS x, 0 AS n
FROM dbo.[dutmast]
WHERE LEN(dut_eosonum)>0
UNION ALL
SELECT a.s, SUBSTRING(a.s, n+1, 1) AS x, n+1 AS n FROM a WHERE n<LEN(a.s))
SELECT x, COUNT(*) AS c FROM a WHERE n>0 GROUP BY x ORDER BY x
OPTION(MAXRECURSION 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment