Normal spaces
Before and after spaces, use LTrim and RTrim, for example: LTrim (RTrim (Name))
Middle space, replace with replace function, for example: replace (Name, ' ', ')
If it is an ordinary space, it is easy to replace, but sometimes encounter some special spaces, it is more troublesome, it looks like the ordinary space, but it is unable to replace. This requires a special way to find the space and replace it with replace.
To find such a space, you need to use the ASCII function, through the ASCII function, find out the ASCII value of the space, and then replace with the Replace function +char function.
For example, using the ASCII function to find the ASCII value of a space is 9, replace with replace (Name,char (9), ').
In the way above, it is just how to find the ASCII value of the space.
Suppose name has a value of "Zhang San", followed by a special space.
Select ASCII (replace (name, ' Zhang San ', ') from table name where id=**
Take the value of name and replace it with the text, and the extra space will be the ASCII function to get the space ASCII value.
SQL Server database table field values have spaces, how to remove spaces (such as char (5) when the data is less than 5 bits when SQL Server automatically fill the blanks)