I'm looking for a way to apply an arbitrary number of nested REPLACE calls on a column. Ideally the pattern and replace values will come from a configuration table, e.g.:
╔═════════╦═════════╗
║ Pattern ║ Replace ║
╠═════════╬═════════╣
║ -JAN- ║ /01/ ║
║ -FEB- ║ /02/ ║
║ -MAR- ║ /03/ ║
║ -APR- ║ /04/ ║
║ -MAY- ║ /05/ ║
║ etc. ║ ║
╚═════════╩═════════╝
The question is basically the same as this one, but the answer given only works when assigning the result of one input value at a time - I'd like to return the entire resultset.
I was thinking something like a recursive CTE might work..
Sample data
╔═══════════════╦══════════════╗
║ Input ║ Output ║
╠═══════════════╬══════════════╣
║ DataData-JAN- ║ DataData/01/ ║
║ -APR--MAY- ║ /04//05/ ║
║ -MAR-TESTING ║ /03/TESTING ║
╚═══════════════╩══════════════╝