dbTalk Databases Forums  

Basic DTS Transformation Problem - Need Help

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


Discuss Basic DTS Transformation Problem - Need Help in the microsoft.public.sqlserver.dts forum.



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

Default Basic DTS Transformation Problem - Need Help - 01-06-2005 , 10:49 AM






Hi all --

I'm trying to write my own ActiveX transformation script to copy some fields
from an old table using a couple different data types to a new table. I
seem to be having problems with the different data types and can't get DTS
to run with them. I'm sure it's just due to my in-experience with DTS.

Here is a sample of the code:

'************************************************* *********************
' Visual Basic Transformation Script
'************************************************* ***********************

' Copy each source column to the destination column
Function Main()
Dim PercentUp

DTSDestination("ProcessDate") = DTSSource("Date") ' this line works
DTSDestination("DB") = DTSSource("DB") ' this line works
DTSDestination("ExpectedMinsUp") = DTSSource("PotentialUptime") ' this
line works
DTSDestination("MinsDown") = DTSSource("TotaldowntimeMin") ' this line
works

' this line fails
DTSDestination("PercentDown") =CINT(( DTSSource("TotalDowntimePrc")) * 100)
* 100

The source datatype is Decimal(5,4) and the destination is a integer.
Essentially, I want to multiple the source by 100 twice to get the
percentage value. Then I want to store the result in the destination. For
example, the source may be .2807 and I want to multiple it by 100 to return
28.07 then by 100 again to return the integer vale of 2807. Once the value
is 2807, my SQL queries that pull the value will divid by 100 to get the
percentage of 28.07%

Next, I have a new field in my destination column that stores the computed
"UpTime" percent. To compute, I need to divid the source
"totaldowntimemins" by source potentialuptime to get the percentage. I will
likely need to multiple by 100 to get the decimal value to move in the
position
that I need for the destination.

' this line also fails
PercentUp = DTSSource("TotalDowntimeMin") / DTSSource("PotentialUptime")

' this line fails - going from source of decimal(5,2) to integer for
destination
DTSDestination("PercentUp") = DTSSource("TotalDowntimePrc")

Main = DTSTransformStat_OK
End Function

Once I get this routine to work, I need to modify the DTS with a WHERE
clause to only transform rows between Jan-1-04 to Jul-23-04. Where do I do
this? I believe I selected "table" copy originally and then deleted the
default transformation and created my own. Will this work this way?


Any help would be appreciated.



Reply With Quote
  #2  
Old   
The Margolins
 
Posts: n/a

Default Re: Basic DTS Transformation Problem - Need Help - 01-09-2005 , 01:51 PM






David,

What does the error description say?

Ilya

"DavidM" <spam (AT) spam (DOT) net> wrote

Quote:
Hi all --

I'm trying to write my own ActiveX transformation script to copy some
fields
from an old table using a couple different data types to a new table. I
seem to be having problems with the different data types and can't get DTS
to run with them. I'm sure it's just due to my in-experience with DTS.

Here is a sample of the code:

'************************************************* *********************
' Visual Basic Transformation Script
'************************************************* ***********************

' Copy each source column to the destination column
Function Main()
Dim PercentUp

DTSDestination("ProcessDate") = DTSSource("Date") ' this line works
DTSDestination("DB") = DTSSource("DB") ' this line works
DTSDestination("ExpectedMinsUp") = DTSSource("PotentialUptime") ' this
line works
DTSDestination("MinsDown") = DTSSource("TotaldowntimeMin") ' this line
works

' this line fails
DTSDestination("PercentDown") =CINT(( DTSSource("TotalDowntimePrc")) *
100)
* 100

The source datatype is Decimal(5,4) and the destination is a integer.
Essentially, I want to multiple the source by 100 twice to get the
percentage value. Then I want to store the result in the destination.
For
example, the source may be .2807 and I want to multiple it by 100 to
return
28.07 then by 100 again to return the integer vale of 2807. Once the
value
is 2807, my SQL queries that pull the value will divid by 100 to get the
percentage of 28.07%

Next, I have a new field in my destination column that stores the computed
"UpTime" percent. To compute, I need to divid the source
"totaldowntimemins" by source potentialuptime to get the percentage. I
will
likely need to multiple by 100 to get the decimal value to move in the
position
that I need for the destination.

' this line also fails
PercentUp = DTSSource("TotalDowntimeMin") / DTSSource("PotentialUptime")

' this line fails - going from source of decimal(5,2) to integer for
destination
DTSDestination("PercentUp") = DTSSource("TotalDowntimePrc")

Main = DTSTransformStat_OK
End Function

Once I get this routine to work, I need to modify the DTS with a WHERE
clause to only transform rows between Jan-1-04 to Jul-23-04. Where do I
do
this? I believe I selected "table" copy originally and then deleted the
default transformation and created my own. Will this work this way?


Any help would be appreciated.





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.