I am executing an SSIS package. The package imports an excel file into a SQL Server database 2008.
I have set the FIRE_TRIGGERS option during the excel import.
If after the INSERT there is a certain condition,I want to stop the execution of the package.
However I tried many things, but I was not successful. I stripped down the trigger to just raise an error at every insert.However, the SSIS package does not stop. It does stop later because the sproc fails to execute if duplicate records are found.I would like it to stop after the trigger is fired.
Thank for you help
Code for my Trigger:
ALTER TRIGGER [dbo].[TrigInsertBill]
ON [Invoice].[dbo].[Bill]
AFTER INSERT
AS
BEGIN
RAISERROR('This month/year combo exist in the BILL TABLE',16,1)
END
Personally what I would suggest is to load the Excel file into a staging table.
then add an Execute SQL task to check for the condition(s) you want to check for and raise an error there not in a trigger. That is how I stop my packages when there is a specifc condition that the file cannot contain.
If you want to simply skip the bad records, that is a different process. You could use a Conditional Split to identify the records you don’t want and send them to an exception table.