SqlServer removes string spaces and SQL Server strings
Speaking of removing spaces at the beginning and end of a string, you must be the first to think of the trim () function. However, this function is not available in sqlserver, but instead of ltrim () and rtrim () two functions. We can see that everyone knows what to do. ltrim () removes spaces on the left of the string and rtrim () removes spaces on the right of the string, you just need to remove spaces at the beginning and end and use these two functions at the same time.
Test:
Select ltrim ('test') -- remove spaces on the left select rtrim ('test') -- remove spaces on the right select ltrim (rtrim ('test') -- remove spaces at the beginning and end
Result:
The space on the right has been removed, but it cannot be seen here. If we copy the data, we can see that the space has been removed.