I have trailing spaces in a column in a SQL Server table called Company Name
.
All data in this column has trailing spaces.
I want to remove all those, and I want to have the data without any trailing spaces.
The company name is like "Amit Tech Corp "
I want the company name to be "Amit Tech Corp"
Try
SELECT LTRIM(RTRIM('Amit Tech Corp '))
LTRIM
- removes any leading spaces from left side of stringRTRIM
- removes any spaces from rightEx:
To just trim trailing spaces you should use
However, if you want to trim all leading and trailing spaces then use this
The best way to remove all the spaces is SELECT REPLACE("Amit Tech Corp ",' ','')
Instead of LTRIM & RTRIM
Example:
Result:
'Sample'
Use the TRIM SQL function.
If you are using SQL Server try :