Get String Composition
SQL Server 2000: Tested
SQL Server 2005: Tested
SQL Server 2008: Tested
SQL Server 2008R2: Tested
SQL Server 2012: Not Tested
Date: 20 Jun 2012
This function parses a character string and returns a count of the types of characters that make up the string.
Characters are currently split into 4 categories:
Special (e.g. punctuation)
Non-Printable (e.g CR, LF)
The function may be easily extended to produce additional counts.
There are 2 versions of the function:
SCALAR function which utilises a loop and which will work across all versions of SQL Server
TABLE VALUED function which makes use of CTE and the function udf_NumbersTable() to parse the string in one go and which will only work from SQL Server 2005 onwards.
SCALAR function (SQL Server - all versions):
TABLE VALUED function (SQL Server 2005 onwards):