Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Upsert on a lookup field

Hi.
I would like to know how would I reference a lookup field in a sql script

In the below
I am trying to update the Branch lookup field on an Account below:

CREATE PROC [dbo].[IMPORT_ACCOUNTS]
AS
BEGIN

PRINT 'Upserting Business Accounts'

IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('Account_Load') AND type in (N'U'))
DROP TABLE [dbo].Account_Load

SELECT DISTINCT
'BusinessAccount' AS [RecordType.DeveloperName],
[EXT_ID] as External_Customer_Number__c,
[NAME] as Name,
[BRANCH_CODE] as [Branch__c.Branch_Code__c],

INTO dbo.Account_Load
FROM LOCALDATA.dbo.BUSINESS_CUSTOMER

ALTER TABLE Account_Load
ADD ERROR nvarchar(4000);

ALTER TABLE Account_Load
ADD ID nvarchar(18);

EXEC SF_BulkOps 'upsert:bulkapi,parallel,batchsize(100)','LINKEDSERVER', Account_Load, External_Customer_Number__c

SELECT COUNT(*) AS ErrorRows FROM Account_Load
WHERE ERROR NOT LIKE '%Operation Successful%';

PRINT 'Business Account Upsert Completed'
END

EXEC [IMPORT_ACCOUNTS]
1 person has
this question
+1
Reply