Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Redirect Error Rows in Script component

Author  Topic 

on7june
Starting Member

41 Posts

Posted - 2010-04-19 : 01:56:46
How to redirect error rows from script component? I tried using Try catch exception but the problem is whenever the script finds an error it enters catch block and exits script component. So it doesn't read other input records. My requirement is whenever the error rows found I want to redirect the error rows to an error output column.

Sarvan

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-19 : 04:53:12
what are you trying to do inside script? may be you could set a variable based on result of your operation inside script and then use precedence constraint with expression to control flow of program based on result variable.


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

on7june
Starting Member

41 Posts

Posted - 2010-04-19 : 05:26:50
I am using script component as a source. So i reading a flat file which has fixed width length of 10000. I am using substring of input record and assigning to each output column. The requirement for me is, the way we used to redirect error rows in flat file source when truncation or error occurs like wise i need to redirect these columns to the script output column. I can even do a typecast operation inside the script or any functions.

Sarvan
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-19 : 05:36:11
or you can do one thing. Inside script task look for truncation cases and add a derived column with values 1 or 0. then as next step put a conditional split and based on this new derived column create the new outputs for redirection or main flow path.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

on7june
Starting Member

41 Posts

Posted - 2010-04-19 : 05:38:05
How to check for truncation case and error records?Please advice me.

Sarvan
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-19 : 05:43:59
this is a way to simulate redirection in script task
http://msdn.microsoft.com/en-us/library/ms345159(v=SQL.100).aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

on7june
Starting Member

41 Posts

Posted - 2010-04-19 : 06:17:41
Thanks for sharing the link so do i need to check whether each column under goes truncation if so then i need to direct that row to the newly created error column.

Sarvan
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-19 : 06:18:58
exactly

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

on7june
Starting Member

41 Posts

Posted - 2010-04-19 : 06:21:46
Thanks a lot for your replies. So we need to have all the error conditions inside the script and redirect the error records. Like type cast errors, truncation errors etc..

Sarvan
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-19 : 06:32:01
yup..depending on what all you want to check

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -