Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Remove ANY number of spaces except one space?

Author  Topic 

kunato
Starting Member

1 Post

Posted - 2007-03-24 : 14:02:37
Hi,

I am using MS ACCESS and I have one table with 15 columns and thousands of data. I would like to replace ANY number of spaces IN BETWEEN the words in any of my columns with a single space.

E.g. If I want to remove 5 spaces in a column names "name" it would be:

TRIM(replace(replace(replace(replace(replace(name,' ',' '),' ',' '),' ',' '),' ',' '),' ',' '))

But, this is long and wordy, let alone making sure you've got the right number of brackets...

The issue is also that the above SQL returns an ERROR if any of the records within the "name" column has a NULL value.

Is there a simpler solution?

Thnks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-24 : 14:48:51
There is a special MS Access forum.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -