Showing posts with label fail. Show all posts
Showing posts with label fail. Show all posts

Wednesday, March 21, 2012

Script task raising OnError Events

Is there a way I can stop a script task of a control flow from raising OnError Events? or Is there a way I can Set Dts.Results to Fail without having the script task raise OnError event.

The reason why I need to fail the task is because I am using Precedence constraints and by setting the status to Fail I can stop the control flow. However, this action raises OnError event. I expect onError event to be raised if there are any exceptions in the script not when the Results is changed to fail.

I have tried capturing the failure into a dummy script, however the OnError event is still raised.

Try putting the code that raises the error in a TRY...CATCH block, that'll stop individual lines of code from throwing errors.
I'm pretty sure though that if you set Dts.TaskResult = Dts.Results.Failure then it'll trigger an OnError event.

-Jamie

|||Failing a task is designed for signalling an error,
and should not be used to drive regular (non
exceptional) control flow.

To alter control flow, a better solution is using
conditions on precedence contraints instead.

You can set some variable in the script task, then
add on-success or on-completed precedence constraint
with condition that checks that variable.

Hope this helps,
Michael [SSIS Technical Lead]|||There are better ways to stop the task without returning failure result from the script task. For example, you could have an expression on the precedence constraint that checks a variable value you set in the script for whether to go on or not.
Try that, it will solve both problems I think.
K|||I have tried setting expressions within precedence constraint and it works. But I find setting variable and changing variable's value little kludge and I am surprised that Script Task does not have a property that will fail precedence constraint without raising an error.

On the contrary end, I guess it makes sense to have script task raise an error if I set it to failure manually, since all the other tasks have similiar behaviour. That is if they fail they raise OnError event.

Thanks everyone.|||

Do you want to force a failure result without actually throwing an error? If so try the ForceExecutionResult property. It is a container property, so available on all tasks.

|||

Hi

I think ive got a similar problem.

We have set up an SSIS package which goes to an FTP site and downloads files.

Everything is fine... EXCEPT (lol) when there are no files to download. This then fails the task.

However, I want the package to continue to run.

Is there away of assigning the error message given to an expression and then using the expression in the precedence contraint?

thanking you in advance

David

sql

Script task raising OnError Events

Is there a way I can stop a script task of a control flow from raising OnError Events? or Is there a way I can Set Dts.Results to Fail without having the script task raise OnError event.

The reason why I need to fail the task is because I am using Precedence constraints and by setting the status to Fail I can stop the control flow. However, this action raises OnError event. I expect onError event to be raised if there are any exceptions in the script not when the Results is changed to fail.

I have tried capturing the failure into a dummy script, however the OnError event is still raised.

Try putting the code that raises the error in a TRY...CATCH block, that'll stop individual lines of code from throwing errors.
I'm pretty sure though that if you set Dts.TaskResult = Dts.Results.Failure then it'll trigger an OnError event.

-Jamie

|||Failing a task is designed for signalling an error,
and should not be used to drive regular (non
exceptional) control flow.

To alter control flow, a better solution is using
conditions on precedence contraints instead.

You can set some variable in the script task, then
add on-success or on-completed precedence constraint
with condition that checks that variable.

Hope this helps,
Michael [SSIS Technical Lead]|||There are better ways to stop the task without returning failure result from the script task. For example, you could have an expression on the precedence constraint that checks a variable value you set in the script for whether to go on or not.
Try that, it will solve both problems I think.
K|||I have tried setting expressions within precedence constraint and it works. But I find setting variable and changing variable's value little kludge and I am surprised that Script Task does not have a property that will fail precedence constraint without raising an error.

On the contrary end, I guess it makes sense to have script task raise an error if I set it to failure manually, since all the other tasks have similiar behaviour. That is if they fail they raise OnError event.

Thanks everyone.|||

Do you want to force a failure result without actually throwing an error? If so try the ForceExecutionResult property. It is a container property, so available on all tasks.

|||

Hi

I think ive got a similar problem.

We have set up an SSIS package which goes to an FTP site and downloads files.

Everything is fine... EXCEPT (lol) when there are no files to download. This then fails the task.

However, I want the package to continue to run.

Is there away of assigning the error message given to an expression and then using the expression in the precedence contraint?

thanking you in advance

David

Wednesday, March 7, 2012

Script a database fail

Dear experts,

I've a database in sql2005 and now I want to build a same one on another machine. I've searched thru google and told that i can use backup& restore or using script. I've tested using backup/restore and it works great now i want to give a test to script. I've script the database successfully to a sql script file, however, when i run it against the new database server, the new database was not created as expected. Could anybody explain why? Thanks in advance

Are you getting any error messages?

|||

How did you create script? Have you tried to create it with Database Publishing Wizard:http://www.microsoft.com/downloads/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en
With this peace of software you can create script directly from Visual Studio and you can choose do you want only schema of your database, or do you want schema and data.