I have a SQL Trigger that doesn't fire because the records in the table are inserted through a BULK INSERT. I do not have access to the code that inserts the records so I need to modify this trigger to handle the BULK INSERT. This is the trigger:
USE [testdata]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[Trigger_test] ON [dbo].[test]
AFTER INSERT , UPDATE
AS
BEGIN
DECLARE @BatchId int, @Ethanol decimal(18,6), @Glucose decimal(18,6), @SampleAge varchar(50);
SELECT @BatchId = CONVERT(int,bd.[BatchId]),
@Ethanol = CONVERT(decimal(18,2),[Ethanol]),
@Glucose= CONVERT(decimal(18,2),[Glucose]),
@SampleAge = bd.SampleCode
from INSERTED bd
update [dbo].[DeSchedule]
SET
[Ethanol] = @Ethanol,
[Glucose] = @Glucose,
[SampleCompleted] = 1
WHERE [BatchID] = @BatchId AND [SampleAge] = @SampleAge
END
Can anyone help me in modifying this trigger to handle the BULK INSERT.