all groups > sql server dts > december 2005 >
You're in the

sql server dts

group:

how to code the transformation script in the DTS process


how to code the transformation script in the DTS process TaeHo Yoo
12/14/2005 1:30:37 AM
sql server dts:
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

Re: how to code the transformation script in the DTS process TaeHo Yoo
12/14/2005 3:09:41 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



Re: how to code the transformation script in the DTS process Darren Green
12/14/2005 10:04:01 AM
[quoted text, click to view]

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
AddThis Social Bookmark Button