dbTalk Databases Forums  

how to code the transformation script in the DTS process

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


Discuss how to code the transformation script in the DTS process in the microsoft.public.sqlserver.dts forum.



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

Default how to code the transformation script in the DTS process - 12-14-2005 , 03:30 AM






Hi all,

I have a table which has 6 columns and a text file which has four
columns that are need to be loaded to the table.
I have set the data source and the destination data. Now the two columns
the text file doesn't have are primary key column and timestamp which
simply should be incremented by 1 and filled with the time of the
transfer respectively. How to edit the transformation code so that I
could fill this column out?

For instance,

Function Main()
'DTSDestination("PrimaryKeyColumnName") = incremental value
DTSDestination("gamingserverid") = DTSSource("gamingserverid")
DTSDestination("casinoid") = DTSSource("casinoid")
DTSDestination("userid") = DTSSource("userid")
DTSDestination("balance") = DTSSource("balance")
'DTSDestination("timestamp") = GETDATE()
Main = DTSTransformStat_OK
End Function


Thanks a lot

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: how to code the transformation script in the DTS process - 12-14-2005 , 04:04 AM






TaeHo Yoo wrote:
Quote:
Hi all,

I have a table which has 6 columns and a text file which has four
columns that are need to be loaded to the table.
I have set the data source and the destination data. Now the two columns
the text file doesn't have are primary key column and timestamp which
simply should be incremented by 1 and filled with the time of the
transfer respectively. How to edit the transformation code so that I
could fill this column out?

For instance,

Function Main()
'DTSDestination("PrimaryKeyColumnName") = incremental value
DTSDestination("gamingserverid") = DTSSource("gamingserverid")
DTSDestination("casinoid") = DTSSource("casinoid")
DTSDestination("userid") = DTSSource("userid")
DTSDestination("balance") = DTSSource("balance")
'DTSDestination("timestamp") = GETDATE()
Main = DTSTransformStat_OK
End Function


Thanks a lot

*** Sent via Developersdex http://www.developersdex.com ***
Create a global variable and use it to store the incrementing key
between rows. Set it up front to the seed you would like, then use it in
the transform-

' Set current ID Value
DTSDestination("PrimaryKeyColumnName").Value =
DTSGlobalVariable("IDVar").Value
' Increment ID Value ready for next row
DTSGlobalVariable("IDVar").Value = DTSGlobalVariable("IDVar").Value + 1

The GETDATE() equivalent in VBS is Now(), so try that for the current
date and time.

--
Darren
http://www.sqldts.com
http://www.sqlis.com


Reply With Quote
  #3  
Old   
TaeHo Yoo
 
Posts: n/a

Default Re: how to code the transformation script in the DTS process - 12-14-2005 , 05:09 AM



Thank you so much Darren,
But I have set the primary key as incremental column so I prefer it to
be sorted out by itself rather than relying on dts process. if there is
no way of doing it. then how to assign the last primary key to the
global variable?
as I have to increment it from the latest primary key value.

Thanks a lot again



*** Sent via Developersdex http://www.developersdex.com ***

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.