Application Note for QuNect ODBC for QuickBase

Delete Quickbase records when SQL Server deletes occur with a trigger

The following stored procedure will delete records in your Quickbase table keeping it in synch with your SQL Server table. It relies on having the Quickbase key field set to the key field in SQL Server. As a result, both of these fields must be included below in the trigger stored procedure.

GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Claude von Roesgen
-- Create date: 2/3/2017
-- Description: Delete Quickbase records when SQL Server deletes occur with a trigger
-- =============================================
-- This stored procedure depends on the existence of a linked server called
-- Quickbase. To create this linked server watch the following video:
--
-- http://qunect.com/flash/linkedServer.html
--
-- After you have your linked server in place you're ready to run the stored 
-- procedure below. 
CREATE TRIGGER [dbo].[triggerForQuickBaseDeletes] 
   ON  [dbo].[yourSQLServerTable] 
   AFTER DELETE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON
	SET XACT_ABORT ON
DELETE FROM QUICKBASE."Your_QuickBase_Application_Name".."Your_QuickBase_Table_Name_bbacdknaw" 
WHERE "QuickBase_Key_Field_Name" IN (SELECT "SQL_Server_Key_Field_Name" FROM DELETED); 
END