01-30-2014 01:04 PM
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
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.
10-31-2014 12:11 AM
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?