If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Spaces within post codes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-27-12, 08:38
Yorkshire Lad Yorkshire Lad is offline
Registered User
 
Join Date: Jan 2011
Posts: 41
Spaces within post codes

Hi,

I am trying to merge two tables of customers and I am working on the POST CODR field. Some have spaces between the letters and other s dont. How do I delete all the spaces in the psot code field?

Thanks

Simon
Reply With Quote
  #2 (permalink)  
Old 01-27-12, 08:44
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
You could use the Replace() function in a query:
Code:
INSERT INTO DestinationTable ( PostCode, some other fields...)
SELECT Replace([PostCode], ' ', ''), some other fields...
FROM SourceTable;
__________________
Have a nice day!
Reply With Quote
  #3 (permalink)  
Old 01-27-12, 08:54
Yorkshire Lad Yorkshire Lad is offline
Registered User
 
Join Date: Jan 2011
Posts: 41
Thanks. So if my table is tblCustomer and the field is PostCode, what is the full syntax to put into the SQL query?
Reply With Quote
  #4 (permalink)  
Old 01-27-12, 10:11
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
I can't provide the full SQL statement as I don't know the names of the columns in both tables (I guess that 'PostCode' isn't the only column), as well as the names of both tables.
__________________
Have a nice day!
Reply With Quote
  #5 (permalink)  
Old 01-27-12, 10:14
Yorkshire Lad Yorkshire Lad is offline
Registered User
 
Join Date: Jan 2011
Posts: 41
At the moment, I just want to work on the one table which is called tblCustomers. It has 2 fields. "Customer" and "PostCode"

I just want to delete all the spaces from that one table.

Is this possible?
Reply With Quote
  #6 (permalink)  
Old 01-27-12, 11:57
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
Yes it is:
Code:
UPDATE TblCustomers SET PostCode = Replace([PostCode], ' ', '');
__________________
Have a nice day!
Reply With Quote
  #7 (permalink)  
Old 01-30-12, 04:21
Yorkshire Lad Yorkshire Lad is offline
Registered User
 
Join Date: Jan 2011
Posts: 41
Thanks very much
Reply With Quote
  #8 (permalink)  
Old 01-30-12, 04:25
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
You're welcome!
__________________
Have a nice day!
Reply With Quote
  #9 (permalink)  
Old 01-30-12, 07:32
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
deleting space ijn postcodes can cause problems using the data down the line. some systems recognise the spaces and some don't. as its trivial to extract the space in a query I wouldn't store the resultant value. IE store M235WE not M23 5WE.
you can regenerate the space if you want to but its tricker than removing.

why would this be a problem?
well some GIS systems look for the space or only work in the first block
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On