We help IT Professionals succeed at work.

SQL 2000 Transformation Script to SQL 2005 Data Flow Task?

irishm20
irishm20 asked
on
606 Views
Last Modified: 2008-09-08
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").Value

        Case "5"        '*****Process Batch Header Row
              DTSGlobalVariables("ServiceClass").Value = ""
                DTSGlobalVariables("CompanyName").Value = ""
                DTSGlobalVariables("CompanyDisc").Value = ""
                DTSGlobalVariables("CompanyId").Value = ""
                DTSGlobalVariables("StandardEntryClass").Value = ""
                DTSGlobalVariables("CompanyEntryDesc").Value = ""
                DTSGlobalVariables("CompanyDescDate").Value = ""
                DTSGlobalVariables("EffectiveEntryDate").Value = ""
                DTSGlobalVariables("SettlementDate").Value = ""
                DTSGlobalVariables("OriginatorStatus").Value = ""
                DTSGlobalVariables("OriginatingDFIId").Value = ""
                DTSGlobalVariables("BatchNumber").Value = ""

         If Mid(DTSSource("TranData"), 50, 3) = "TEL" OR Mid(DTSSource("TranData"), 50, 3) = "WEB" Then

                DTSGlobalVariables("ServiceClass").Value = Mid(DTSSource("TranData"), 1, 3)
                DTSGlobalVariables("CompanyName").Value = Mid(DTSSource("TranData"), 4, 16)
                DTSGlobalVariables("CompanyDisc").Value = Mid(DTSSource("TranData"), 20, 20)
                DTSGlobalVariables("CompanyId").Value = Mid(DTSSource("TranData"), 40, 10)
                DTSGlobalVariables("StandardEntryClass").Value = Mid(DTSSource("TranData"), 50, 3)
                DTSGlobalVariables("CompanyEntryDesc").Value = Mid(DTSSource("TranData"), 53, 10)
                DTSGlobalVariables("CompanyDescDate").Value = Mid(DTSSource("TranData"), 63, 6)
                DTSGlobalVariables("EffectiveEntryDate").Value = DateSerial(Cint(Mid(DTSSource("TranData"), 69, 2)) , Cint(Mid(DTSSource("TranData"), 71, 2)) , Cint(Mid(DTSSource("TranData"), 73, 2)) )
                DTSGlobalVariables("SettlementDate").Value = Mid(DTSSource("TranData"), 75, 3)
                DTSGlobalVariables("OriginatorStatus").Value = Mid(DTSSource("TranData"), 78, 1)
                DTSGlobalVariables("OriginatingDFIId").Value = Mid(DTSSource("TranData"), 79, 8)
                DTSGlobalVariables("BatchNumber").Value = Mid(DTSSource("TranData"), 87, 7)
        
      Else
            DTSGlobalVariables("StandardEntryClass").Value = "nonWebTel"
            'Main = DTSTransformStat_SkipRow
      End If

       Case "6"        '*****Process Entry Detail Record

      If DTSGlobalVariables("StandardEntryClass").Value <> "nonWebTel" Then

              DTSDestination("PostDate") = DTSGlobalVariables("EffectiveEntryDate").Value
                DTSDestination("TranType") = DTSGlobalVariables("StandardEntryClass").Value
                DTSDestination("CompanyName") = DTSGlobalVariables("CompanyName").Value
                DTSDestination("AccountNumber") = Mid(DTSSource("TranData"), 12, 17)
                DTSDestination("Amount") = FormatCurrency(Cdbl(Mid(DTSSource("TranData"), 29, 10))*.01,2)
                DTSDestination("IndividualName") = Mid(DTSSource("TranData"), 54, 22)
      Else
            DTSGlobalVariables("StandardEntryClass").Value = "nonWebTel"
            'Main = DTSTransformStat_SkipRow
      End If

Case Else
      'Main = DTSTransformStat_SkipRow
End Select

Main = DTSTransformStat_OK

End Function
Comment
Watch Question

Top Expert 2007

Commented:
You can create a SSIS package using the Visual studio 2005.
There is a task called 'Execute DTS 2000 package task' and that will run your current DTS.
Or you can use a 'ActiveX script task' ... you can enter your ActiveX code in there right away.

Hope this helps ...

Author

Commented:
I've tried to execute the DTS 2000 package and because of the layout of the package I'm having to re-create it in 2005 (Microsoft says I would probably have to if I had certain errors).  I'm not able to use the ActiveX Script task in the data flow piece otherwise that would work great.  Thanks for the attempt though.
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.