I am trying to clear leading and trailing spaces from an NVARCHAR (MAX) column filled with prices (using NVARCHAR due to importing data from several operating systems with odd characters).
At this point, I have a t-sql command that can remove leading / trailing spaces from static prices. However, when it comes to using the same command to remove all prices, I'm at a standstill.
Here's the static script I used to remove a specific price:
UPDATE *tablename* set *columnname* = LTRIM(RTRIM(2.50)) WHERE cost = '2.50 ';
Here I tried to remove all trailing spaces:
UPDATE *tablename* set *columnname* LIKE LTRIM(RTRIM('[.]')) WHERE cost LIKE '[.] ';
I also tried different% variations for random characters, but at this moment I spin my wheels.
What I hope to achieve is to run one simple command that removes all the leading and trailing spaces in each cell of this column without changing any actual column data.
source share