Sql Server Trimming blank spaces
Posted on 2014-11-27
Hi, I have a view which users connect via Excel.
Now I have a table used in the view where there is column named 'NAME' and it has data with spaces at the end
and in between like below :
Andrew - there is single space here right at the end of the word
John - there is double space here right at the end of the word
Gareth Jones - there is double space here in between Gareth and Jones
Thirlestane Endurance E-3120, 36m tower -- there are 3 spaces before the 36m tower
so when in my function, I need to trim these spaces in my select statement like below -
all spaces at the end of the word needs to be removed
all double and more than double spaces in between the texts should be replaced with a Single Space.
Can anyone please give me that code which I can use in my SELECT ?