Hey Alvin,
What’s the error message you’re getting? Is it something like “The target table '<table name>' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.”?
If so, I can tell you that at least one user has been able to work around that limitation by having the Zapier action issue the primary key.
Let me know about the error message and whether or not that workaround works for you…
Thanks!
Yes that is the error: (pyodbc.ProgrammingError) ('42000', ""42000] FreeTDS]]SQL Server]The target table 'tblLeadRawData' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause. (334) (SQLExecDirectW)") SQL: 'INSERT INTO tblLeadRawData] ((HomePhone], AltPhone], Email], FirstName], LastName], Address], City], State], ZipCode], VendorCode], Campaign], Note], PipeLine], Stage], IPAddress]) OUTPUT inserted..LeadReferenceID] VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'] parameters: ('3123583659', '3123583659', 'xueqing40@gmail.com', 'Qing', 'Xue-Hope-Test', '5725 California Circle', 'Banning', 'CA', '92220', 'DMS', 'Upside Legal', '0', 'Upstart Pipeline', 'Lead', '42.111.145.246')] (Background on this error at: http://sqlalche.me/e/f405)
Do I put the output in the SQL trigger and where, top, bottom, middle? If the Zapier action, how do I do that? Here is the SQL trigger:
DECLARE @TMZ as nvarchar(4)
DECLARE @ZipCode as varchar(50)
DECLARE @LeadReferenceID as int
SET NOCOUNT ON;
SELECT @ZipCode=INSERTED.ZipCode, @LeadReferenceID=INSERTED.LeadReferenceID from INSERTED
SELECT @TMZ=/T/Z] FROM tblZipCodeTMZ WHERE 1=1 and ZIP=@ZipCode
UPDATE tblLeadRawData
SET TimeZone=@TMZ,
LeadCreated=convert(nvarchar(12), getdate(), 110),
Stage='Lead',
PipeLine='Upstart Pipeline',
Campaign='(U10) Upside Lead Gen Debt - ' + @TMZ
WHERE 1=1
and LeadReferenceID = @LeadReferenceID