I am running an Execute SQL Task statement in my SSIS package. The Execute SQL Task is running sql and checking that the tables have more than 1000 rows. If they have less than 1000 rows, I want to fail the package.
How do I force a fail inside of a SQL statement?
Reasons that the package may have failed are as follows: The user account that is used to run the package under SQL Server Agent differs from the original package author. The user account does not have the required permissions to make connections or to access resources outside the SSIS package.
AFAIK, tasks in SSIS fail on error. So if your Execute SQL Task has a statment like so in it:
declare @count int
select @count = select count(*) from my_table
if @count < 1000
begin
raiserror('Too few rows in my_table',16,1)
end
else
begin
-- Process your table here
end
You should get the results you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With