dbTalk Databases Forums  

DTS Import from file split field create multiple records

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


Discuss DTS Import from file split field create multiple records in the microsoft.public.sqlserver.dts forum.



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

Default DTS Import from file split field create multiple records - 09-16-2005 , 04:06 AM






Hi guys,

I am creating a DTS in SQL server by importing from a tab sep file,
I realized that one field could contain multiple, comma separeted,
values: eg.
Field1 Field2 Field3 Date etc..
Normal:
160 2827863 15489229 2005-03-07 21:10 ....
Exeption:
197 2827867 15200387,2371987239,02109283,23812319,120310928310
2005-03-07 21:19 ....

I'd like to know if it possible to do the following, which conceptually
is not difficult.
So I my idea was while it is copying the Source fields into the
destination ones perform a check and if the field is multple then create
more records in that table:
here is the stupid code I wrote in the DTSTransformation ActiveX
Transformation windows
Function Main()
Dim SplittedCells
Dim CellContent
SplittedCells = Split(DTSSource("Col003"), ",")
For i = LBound(SplittedCells) To UBound(SplittedCells) Step 1
DTSDestination("TaxID") = DTSSource("Col001")
DTSDestination("GeneID") = DTSSource("Col002")
DTSDestination("LastUpdate") = DTSSource("Col004")
DTSDestination("GeneRifText") = DTSSource("Col005")
DTSDestination("PubmedID") = SplittedCells(i)
---> Here there should be an .Addnew-like command...and .Update-like
also <---
Next
Main = DTSTransformStat_Ok
End Function

My question is: is there anybody who knows if it is possible to do...if
it is the correct way...
Thanks in advance...

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: DTS Import from file split field create multiple records - 09-17-2005 , 02:31 AM






This article should help you


Processing The Same Row More Than Once
(http://www.sqldts.com/default.aspx?266)



Allan

"P.Guarnieri (AT) cmbi (DOT) ru.nl" <P.Guarnieri (AT) cmbi (DOT) ru.nl> wrote


Quote:
Hi guys,

I am creating a DTS in SQL server by importing from a tab sep file,
I realized that one field could contain multiple, comma separeted,
values: eg.
Field1 Field2 Field3 Date etc..
Normal:
160 2827863 15489229 2005-03-07 21:10 ....
Exeption:
197 2827867 15200387,2371987239,02109283,23812319,120310928310
2005-03-07 21:19 ....

I'd like to know if it possible to do the following, which conceptually
is not difficult.
So I my idea was while it is copying the Source fields into the
destination ones perform a check and if the field is multple then create
more records in that table:
here is the stupid code I wrote in the DTSTransformation ActiveX
Transformation windows
Function Main()
Dim SplittedCells
Dim CellContent
SplittedCells = Split(DTSSource("Col003"), ",")
For i = LBound(SplittedCells) To UBound(SplittedCells) Step 1
DTSDestination("TaxID") = DTSSource("Col001")
DTSDestination("GeneID") = DTSSource("Col002")
DTSDestination("LastUpdate") = DTSSource("Col004")
DTSDestination("GeneRifText") = DTSSource("Col005")
DTSDestination("PubmedID") = SplittedCells(i)
---> Here there should be an .Addnew-like command...and .Update-like
also <---
Next
Main = DTSTransformStat_Ok
End Function

My question is: is there anybody who knows if it is possible to do...if
it is the correct way...
Thanks in advance...


Reply With Quote
  #3  
Old   
Paolo
 
Posts: n/a

Default Re: DTS Import from file split field create multiple records - 09-19-2005 , 09:08 AM



Allan Mitchell wrote:
Quote:
This article should help you


Processing The Same Row More Than Once
(http://www.sqldts.com/default.aspx?266)



Allan

"P.Guarnieri (AT) cmbi (DOT) ru.nl" <P.Guarnieri (AT) cmbi (DOT) ru.nl> wrote in message
news:AUvWe.30615$nT3.7214 (AT) tornado (DOT) fastwebnet.it:

Hi guys,

I am creating a DTS in SQL server by importing from a tab sep file,
I realized that one field could contain multiple, comma separeted,
values: eg.
Field1 Field2 Field3 Date etc..
Normal:
160 2827863 15489229 2005-03-07 21:10 ....
Exeption:
197 2827867 15200387,2371987239,02109283,23812319,120310928310
2005-03-07 21:19 ....

I'd like to know if it possible to do the following, which conceptually
is not difficult.
So I my idea was while it is copying the Source fields into the
destination ones perform a check and if the field is multple then create
more records in that table:
here is the stupid code I wrote in the DTSTransformation ActiveX
Transformation windows
Function Main()
Dim SplittedCells
Dim CellContent
SplittedCells = Split(DTSSource("Col003"), ",")
For i = LBound(SplittedCells) To UBound(SplittedCells) Step 1
DTSDestination("TaxID") = DTSSource("Col001")
DTSDestination("GeneID") = DTSSource("Col002")
DTSDestination("LastUpdate") = DTSSource("Col004")
DTSDestination("GeneRifText") = DTSSource("Col005")
DTSDestination("PubmedID") = SplittedCells(i)
---> Here there should be an .Addnew-like command...and .Update-like
also <---
Next
Main = DTSTransformStat_Ok
End Function

My question is: is there anybody who knows if it is possible to do...if
it is the correct way...
Thanks in advance...


It took me awhile to understand a couple of things (ie. I didn't know
about global variables concept!), but actually it really help! I solved
the problem!
Thanks a lot!


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.