Link to home
Start Free TrialLog in
Avatar of Tom Crowfoot
Tom CrowfootFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Show Single Duplicate

Dear Experts

I have an Access 2010 database which has a table called Permanent Bookings.  This table contain data regarding companies and contacts at companies.  This table is populated via an “append data import” from excel. This produces records like this:

Contact name > contact jobtitle> company name> Company GUID > Company Address
Joe Blogs > team head > Microsoft > 1234gqrdwer23 > USA
Fred Smith > team player > Microsoft > 1234gqrdwer23 > USA
David White  >tea boy > Microsoft > 1234gqrdwer23 > USA

What I am trying to do is append just 1 copy of the company information into another table (Permanent Companies) i.e. it will only import 1 copy of

company name> Company GUID > Company Address
Microsoft > 1234gqrdwer23 > USA

The field that defines the duplicate is Company GUID

Can anybody help?
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

make the field "Company GUID" a primary key, with no duplicates.

 
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
another way is to dump the imported records from excel into  a temp table, then run this append query

insert into [Permanent Bookings]
select tmpTable.* from tempTable
where exists(select [Permanent Bookings].[Company GUID] from [Permanent Bookings] where [Permanent Bookings].[Company GUID] =[tmpTable].[Company GUID])=false
Avatar of Tom Crowfoot

ASKER

Works an abolsute treat - thank you very much
I think what you want is:

INSERT INTO [Permanent Companies] ([Company GUID], [Company Name]) SELECT DISTINCT [Permanent Bookings].[Company GUID], [Permanent Bookings].[Company Name] FROM [Permanent Bookings]