Community
Showing results for 
Search instead for 
Do you mean 
Reply

Importing Contacts and linking them to Companies

New Member
Posts: 1
Country: USA

Re: Importing Contacts and linking them to Companies

 

if you are just connecting up a simple CONTACT/COMPANY to COMPANY, here is the code you run and it will do everything for you:

 

INSERT INTO dbo.TBL_COMPANY_CONTACT
                            (COMPANYID, CONTACTID)                            
select TBL_COMPANY.COMPANYID, TBL_CONTACT.CONTACTID
FROM dbo.TBL_CONTACT, dbo.TBL_COMPANY
where dbo.TBL_CONTACT.COMPANYNAME = dbo.TBL_COMPANY.NAME

if you run SQL Server Profiler, you'll see that's all Act! does under the sheets when you join a contact to a company.

 

very simple and straightforward. i just joined over 1500 contacts to companies in less than 1 second.

 

New Member
Posts: 1
Country: USA

Re: Importing Contacts and linking them to Companies

Good work!

but I correct your script

INSERT INTO kr_test.dbo.TBL_COMPANY_CONTACT (COMPANYID, CONTACTID)
select kr_test.dbo.TBL_COMPANY.COMPANYID, kr_test.dbo.TBL_CONTACT.CONTACTID
FROM kr_test.dbo.TBL_CONTACT, kr_test.dbo.TBL_COMPANY
where (kr_test.dbo.TBL_CONTACT.COMPANYNAME = kr_test.dbo.TBL_COMPANY.NAME) and not exists (select CONTACTID from kr_test.dbo.TBL_COMPANY_CONTACT where CONTACTID = kr_test.dbo.TBL_CONTACT.CONTACTID) and kr_test.dbo.TBL_CONTACT.CREATEDATE > '2014-10-30'

 

linking contacts to the company successful. But there is no reverse linking, contacts are not linked to companies. How to automate this process?