I have a ForEach loop that processes a list of databases. Inside the loop I many steps, one of which is a sequence that contains two steps. Either of these steps may fail (they are attempting to start mirroring and could fail for any number of reasons). I would like to trap this error and ignore it so the For loop will continue, but still fail if other steps than this one fail. The only thing I've been able to do so far is to tell the whole loop to continue through some insane number of errors. Is there a way to identify or actually ignore the error? In the sequence I have have on completion and from the sequence to the next step (which checks if mirroring actually started) is running on completion.
Thanks.
I found a solution using SQL Server.
BEGIN TRY
ALTER DATABASE AdventureWorks SET Partner='http://TEST'
END TRY
BEGIN CATCH
END CATCH
This will prevent the error from being seen by SSIS. But for other errors this will not work (such as SELECT * FROM person.contacts) where contacts does not exist in the adventureworks database (person.contact does).
I'd still be interested in any feedback on ways to selectively trap and ignore errors and get the for loop to continue.
Larry
|||For selectively ignoring an error, one approach I've used it to modify the MaximumErrorCount to greater than 1 (say 1 billion) on the task (or container) I want to selectively ignore errors on. Then, put an error handler on the task or container which basically sets a variable for fatal errors and use expression based precedence constraints rather than success/failure/completion precedence constraints.
Public Sub Main()
' Don't propagate error message up the chain, is this propagated
Dim errorMessage As String
Dts.Variables("Propagate").Value = False
'inspect error message
errorMessage = CType(Dts.Variables("ErrorDescription").Value, String)
If errorMessage.Contains("really bad error here") Then
Dts.Variables("FatalError").Value = True
End If
Dts.TaskResult = Dts.Results.Success
End Sub
No comments:
Post a Comment