Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I Bypass Loading flat rec's into a SQL Table

Status
Not open for further replies.

btturner

Programmer
May 17, 2001
175
US
Using a DTS ActiveX script, I am DTS'ing a flat file to a table.

In this DTS process, how do I bypass the loading of selected rows?

EXAMPLE: If the LW_GROUP_ID is NOT NUMERIC, I want to BYPASS the LOADING of this Record into the SQL Server table

'Visual Basic Transformation Script

'Copy each source column to the destination column Function Main()

DTSDestination("log_date") = DTSSource("Col001")
If IsNumeric(DTSSource("Col002")) Then
DTSDestination("lw_group_id") = DTSSource("Col002")
Else
DTSDestination("lw_group_id") = 0
End If
Main = DTSTransformStat_OK
End Function

 
Use DTSTransformStat_SkipInsert

Example:

Function Main()
If IsNumeric(DTSSource("Col020")) Then
DTSDestination("log_date") = DTSSource("Col001")
DTSDestination("log_time") = DTSSource("Col002")
Else
Main = DTSTransformStat_SkipInsert
Exit Function
End If
Main = DTSTransformStat_OK
End Function

 
First, I agree with btturners method, but I like to format the syntax as such:
Code:
Function Main()
If IsNumeric(DTSSource("Col020")) Then
   DTSDestination("log_date") = DTSSource("Col001")
   DTSDestination("log_time") = DTSSource("Col002")
   Main = DTSTransformStat_OK
Else
   Main = DTSTransformStat_SkipInsert
End If
End Function
Perhaps just personal preference, but it works for me.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top