dbTalk Databases Forums  

Need script for processing next row of data if error is encountered in row

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Need script for processing next row of data if error is encountered in row in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Elgar Esteban
 
Posts: n/a

Default Need script for processing next row of data if error is encountered in row - 07-03-2003 , 09:14 PM






Hi!

I am a newbie to DTS. Below is a sample code which copies
the data from a source text file to a destination text
file.

Assuming that there are 3 columns in the source text,
if one of the rows has a missing column (the last column),
DTS encouters an error and then stops processing the
succeeding rows. What is the best way to make DTS continue
processing those rows of data even if an error is
encountered (which is then logged into an error log).

Your help will be very much appreciated.

Thanks.

Elgar



'************************************************* *********
************
' Visual Basic Transformation Script
'************************************************* *********
**************

' Copy each source column to the destination column
Function Main()
DTSDestination("name") = DTSSource("name")
DTSDestination("company") = DTSSource("company")
DTSDestination("phone") = DTSSource("phone")

' Check if any is NULL
MsgBox DTSSource("name")
MsgBox DTSSource("company")
MsgBox DTSSource("phone")

If DTSSource("name") = "" OR DTSSource("company") = ""
OR DTSSource("phone") = "" Then
Main = DTSTransformStat_SkipRow
Else
Main = DTSTransformStat_OK
End If
End Function

Data from sample.txt
'name','company','phone'
'employee1','electriccompany','28668989'
'employee2','electriccompany',
'employee3','company','28668989'





Reply With Quote
  #2  
Old   
Paul Ibison
 
Posts: n/a

Default Need script for processing next row of data if error is encountered in row - 07-04-2003 , 06:16 AM






On the options Tab, increase the max error count
(detfaults to zero) and then on the same tab, add an
exception file. This file will contain the rows which
error. If you want a different file for sourse and
destination errors, you can use 2000 format.
HTH,
Paul

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.