Remove Selected Characters from a String
SQL Server 2000: Not Supported **
SQL Server 2005: Tested
SQL Server 2008: Tested
SQL Server 2008R2: Tested
SQL Server 2012: Not Tested
Date: 6 Jun 2012
This function originally arrived as one that removed non-alphabetic characters from a string and contained code to create a numbers table. I realised 2 things:
The screening of non-alphabetic characters used a REGEX that could easily be passed in as a parameter, thus expanding the flexibility of the function
The locally produced numbers table and CTE that precluded use on SQL 2000 could be replaced by a function. This numbers table function has several versions, valid across all SQL versions.
The function is now less complex. It utilises the custom numbers table to copy only the characters in the input string to the output string that match the REGEX criteria passed in.
**NOTE: The code as it stands is not supported on SQL Server 2000. However, replacing the udf_NumbersTable function using CTE with the one that is SQL 2000 compliant (available from the same link), should enable it to function.