Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server : How to replace whitespaces(&nbsp, ASCII) in a string with numbers?

This works select replace('string with space',' ','') and returns stringwithspace.

This does not work select replace('8 190',' ',''), it returns 8 190

This is the same select replace('8 190',' ','') returns 8 190.

Why doesn't it work?

like image 867
Claudiu Haidu Avatar asked Sep 01 '25 10:09

Claudiu Haidu


1 Answers

The string_pattern needs to contain the ASCII code 160 for the space &nbsp

SELECT REPLACE('8 190', char(160),'')
like image 71
Matt Avatar answered Sep 03 '25 02:09

Matt