dbTalk Databases Forums  

How to do processing of a load file record by record

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


Discuss How to do processing of a load file record by record in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Karen Middleton
 
Posts: n/a

Default How to do processing of a load file record by record - 03-18-2005 , 11:23 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
Karen

Reply With Quote
  #2  
Old   
Francesco Anti
 
Posts: n/a

Default Re: How to do processing of a load file record by record - 03-18-2005 , 11:41 AM







"Karen Middleton" <karenmiddleol (AT) yahoo (DOT) com> wrote

Quote:
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
Karen
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





Reply With Quote
  #3  
Old   
John Baker
 
Posts: n/a

Default Re: How to do processing of a load file record by record - 03-19-2005 , 07:54 AM



Karen Middleton wrote:
Quote:
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.
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



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.