I've a table in a (MS) SQL database which has an Id column (identity, int) and a Name column (varchar(250)). However, the values in the name column contain (fairly random) leading and trailing spaces as I think they were cut and pasted from "something else" (no idea what!).
Is it possible in T-SQL to do the following:
update MyTable set Name = trim(name)
and have it update all the Name columns with the trimmed value?
MS SQL does not have a trim function. You'll need to use rTrim and lTrim together.
update MyTable set Name = lTrim(rTrim(name))