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 string
RTRIM
- removes any spaces from right
In SQL Server 2017 or later:
TRIM
- removes any spaces from left and right
Ex:
update table set CompanyName = LTRIM(RTRIM(CompanyName))