SQL Server 2005 from SQL Server 2000
I have a "transformation script" in SQL Server 2000 that I would like to convert/use in SQL Server 2005 but I'm not sure the best route to take or how to make it work for that matter. The idea behind the script is to evaluate a column and based upon a value, multiple destination columns are derived from a single source column. Again, I'm not sure how to do this in the "Data Flow Task" of SQL Server 2005, any ideas? Here's my old SQL Server 2000 script:
'*************************
**********
**********
**********
**********
*****
' Visual Basic Transformation Script
'*************************
**********
**********
**********
**********
*******
' Copy each source column to the destination column
Function Main()
Select Case DTSSource("TranCode").Valu
e
Case "5" '*****Process Batch Header Row
DTSGlobalVariables("Servic
eClass").V
alue = ""
DTSGlobalVariables("Compan
yName").Va
lue = ""
DTSGlobalVariables("Compan
yDisc").Va
lue = ""
DTSGlobalVariables("Compan
yId").Valu
e = ""
DTSGlobalVariables("Standa
rdEntryCla
ss").Value
= ""
DTSGlobalVariables("Compan
yEntryDesc
").Value = ""
DTSGlobalVariables("Compan
yDescDate"
).Value = ""
DTSGlobalVariables("Effect
iveEntryDa
te").Value
= ""
DTSGlobalVariables("Settle
mentDate")
.Value = ""
DTSGlobalVariables("Origin
atorStatus
").Value = ""
DTSGlobalVariables("Origin
atingDFIId
").Value = ""
DTSGlobalVariables("BatchN
umber").Va
lue = ""
If Mid(DTSSource("TranData"),
50, 3) = "TEL" OR Mid(DTSSource("TranData"),
50, 3) = "WEB" Then
DTSGlobalVariables("Servic
eClass").V
alue = Mid(DTSSource("TranData"),
1, 3)
DTSGlobalVariables("Compan
yName").Va
lue = Mid(DTSSource("TranData"),
4, 16)
DTSGlobalVariables("Compan
yDisc").Va
lue = Mid(DTSSource("TranData"),
20, 20)
DTSGlobalVariables("Compan
yId").Valu
e = Mid(DTSSource("TranData"),
40, 10)
DTSGlobalVariables("Standa
rdEntryCla
ss").Value
= Mid(DTSSource("TranData"),
50, 3)
DTSGlobalVariables("Compan
yEntryDesc
").Value = Mid(DTSSource("TranData"),
53, 10)
DTSGlobalVariables("Compan
yDescDate"
).Value = Mid(DTSSource("TranData"),
63, 6)
DTSGlobalVariables("Effect
iveEntryDa
te").Value
= DateSerial(Cint(Mid(DTSSou
rce("TranD
ata"), 69, 2)) , Cint(Mid(DTSSource("TranDa
ta"), 71, 2)) , Cint(Mid(DTSSource("TranDa
ta"), 73, 2)) )
DTSGlobalVariables("Settle
mentDate")
.Value = Mid(DTSSource("TranData"),
75, 3)
DTSGlobalVariables("Origin
atorStatus
").Value = Mid(DTSSource("TranData"),
78, 1)
DTSGlobalVariables("Origin
atingDFIId
").Value = Mid(DTSSource("TranData"),
79, 8)
DTSGlobalVariables("BatchN
umber").Va
lue = Mid(DTSSource("TranData"),
87, 7)
Else
DTSGlobalVariables("Standa
rdEntryCla
ss").Value
= "nonWebTel"
'Main = DTSTransformStat_SkipRow
End If
Case "6" '*****Process Entry Detail Record
If DTSGlobalVariables("Standa
rdEntryCla
ss").Value
<> "nonWebTel" Then
DTSDestination("PostDate")
= DTSGlobalVariables("Effect
iveEntryDa
te").Value
DTSDestination("TranType")
= DTSGlobalVariables("Standa
rdEntryCla
ss").Value
DTSDestination("CompanyNam
e") = DTSGlobalVariables("Compan
yName").Va
lue
DTSDestination("AccountNum
ber") = Mid(DTSSource("TranData"),
12, 17)
DTSDestination("Amount") = FormatCurrency(Cdbl(Mid(DT
SSource("T
ranData"),
29, 10))*.01,2)
DTSDestination("Individual
Name") = Mid(DTSSource("TranData"),
54, 22)
Else
DTSGlobalVariables("Standa
rdEntryCla
ss").Value
= "nonWebTel"
'Main = DTSTransformStat_SkipRow
End If
Case Else
'Main = DTSTransformStat_SkipRow
End Select
Main = DTSTransformStat_OK
End Function
Start Free Trial