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?
AFAIK, tasks in SSIS fail on error. So if your Execute SQL Task has a statment like so in it:
You should get the results you want.
I like to force a failure by using a script task. It's really easy.
1) Add the script task
2) Change the line of auto-generated code from :
to
and there you go!
You can create a custom error message like this
You can then call this error using Raiserror()
You need to enter a number greater than 18 for severity (here 20). You need to have admin privileges for this. And dont forget WITH LOG
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.