Groups | Blog | Home
all groups > sql server dts > march 2005 >

sql server dts : How to do processing of a load file record by record


karenmiddleol NO[at]SPAM yahoo.com
3/18/2005 9:23:38 AM
I have a given data file to be loaded into a SQL table. I want a
sample vbscript that shows how I can do processing record by record.
What I am looking for is a mechanism that enables me to process the
incoming record by record for various checks and if a check is not
satisfied to reject or skip the record else to process and load the
record into SQL.

I would be thankful if you could show me a simple script skeleton that
accomplishes this.


Thanks
Francesco Anti
3/18/2005 6:41:49 PM

[quoted text, click to view]

Define an ActiveX script in the trasformation tab. This script is executed
record by record while importing rows. Then add code like this, replacing
<condition> with your condition; in this way you'll add only the record
that match your condition:

Function Main()
DTSDestination("EmployeeID") = DTSSource("EmployeeID")
DTSDestination("LastName") = DTSSource("LastName")
DTSDestination("FirstName") = DTSSource("FirstName")
...
if <Condition> then
Main = DTSTransformStat_OK
else
Main = DTSTransformStat_SkipRow
end if

End Function

Francesco Anti


John Baker
3/19/2005 1:54:35 PM
[quoted text, click to view]

Mr. Anti has already given you a great method. An alternative to this would be to load the whole file and then use SQL
commands to delete the rows that should not be there. There are pros and cons to each approach depending on the situation.
--
To Email Me, ROT13 My Shown Email Address
AddThis Social Bookmark Button