As per your question you want to remove the spaces from left,right and also from middle so we are going to use replace function that is inbuilt function in ms sql
Syntax:
Select replace(columnname,’ ‘,’’)
So query will be
Select replace(‘ a b ’,’ ‘,’’ )