On the special space in SQL Server

Time:2021-4-18

Today, I encountered a very strange problem, that is, in SQL server, using the rtrim() function can’t handle the space on the right side of the string.

Then put the string into the hexadecimal editor to see, this space is different from ordinary space, it is a special space. The ASCII code of our ordinary typed space is 32, while the ASCII code of this special space is 09, so we can’t remove this special space with the rtrim() function.

To remove this special space, replace it with the replace function

Replace (‘string with special space ‘, char (09),’)