Oracle SQL: remove spaces from varchar

Post date: 15-Jul-2010 11:44:11

 

I needed to remove spaces from a varchar2 column. While one can use trim to remove leading and trailing spaces, you need to use a different formula to remove a space inside a string.

 

I used the replace function:

 

select replace ('1234 AB',' ',null) from dual

 

This will replace spaces will a null hence stripping the spaces from the string.