views:

677

answers:

2

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?

+3  A: 

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.

Harper Shelby
You would also have to set the package properties correctly, and possibly set 'failparentonerror'
ConcernedOfTunbridgeWells
raiserror('Too few rows in my_table',16,1)That does the trick! I guess it wasn't so much of an SSIS question and more of a SQL question. Thanks.
Brian Bolton
A: 

You need to make property FailPackageOnFailure true..try to retrieve the property FailPackageOnFailure of the particular task and assign the value true. so that package will be failed.

related questions