How to remove spaces between words and replace with single underscore using 'REPLACE','INSTR' OR 'SUBSTR' oracle function
Something like this might work for you, at least if replace does the same on all your platforms as in SQL Server.


Replace all spaces with space+underscore
Replace underscore+space with an empty string
Replace space with an empty string




replace(replace(replace('my name is            xyz', ' ', '_ '), ' _', ''), ' ', '');