trim all field values in a table

I have a table with several fields. I am trying to trim the spacing in the values in each field.

I know that I can trim a value in a field but how to trim the whole field.

Thanks,
TK
trknssrAsked:
Who is Participating?
 
LowfatspreadCommented:
give an example of your before and after data?

basically

LTRIM(RTRIM(yourcolumn))

or if you mean you have internal spaces...

then Ltrim(RTRIM(REPLACE(YourColumn,'  ',' ')))

will replace multiple internal spaces with just a single space...

0
 
bruintjeCommented:
Hi trknssr,

you can do an update for each column like

update mytable
set myfield1 = LTRIM(RTRIM(myfield1))), myfield2=LTRIM(RTRIM(myfield2))

hope this helps a bit
bruintje
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if you have field that are defined as CHAR(x), you should rather define the m into VARCHAR(x)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.