SQL Server : How to replace whitespaces( , ASCII) in a string with numbers?
14,792
The string_pattern needs to contain the ASCII code 160 for the space  
SELECT REPLACE('8 190', char(160),'')
Comments
-
Claudiu Haidu almost 2 years
This works
select replace('string with space',' ','')
and returns stringwithspace.This does not work
select replace('8 190',' ','')
, it returns 8 190This is the same
select replace('8 190',' ','')
returns 8 190.Why doesn't it work?
-
Claudiu Haidu over 9 yearsYeah, sorry for the typo, I wanted to correct that, as it returned the same result, I later found out that, the space character (' ') was in fact   which has the ASCII code 160.
-
Bhavin Thummar over 4 yearsIt is worked for me. I was directly passed " " in second parameter but when I have passed "char(160)" at second parameter then I got the result and save my time to solved my query related this. Thanks Buddy.