• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

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
0
trknssr
Asked:
trknssr
1 Solution
 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now