Hi
I am trying too build SSIS package for ETL with an access database after migration .
A Collection tool was written that gets the data from excel and transforms / formats , then loads into access.
Ive put here the part of the VBA code used in the tool .
Task at hand:
I need to be able to convert Long text format fields into wider format i.e add 6 rows in a field into 1 long row.
this is what the part of the code in bold is doing 'Assign additional columns from DataSrce' .
Can anyone please advise if this part of code can be rewritten in tsql or which other programming language ? probably for someone that knows VB and SQL Server. help much appreciated
I am trying too build SSIS package for ETL with an access database after migration .
A Collection tool was written that gets the data from excel and transforms / formats , then loads into access.
Ive put here the part of the VBA code used in the tool .
Task at hand:
I need to be able to convert Long text format fields into wider format i.e add 6 rows in a field into 1 long row.
this is what the part of the code in bold is doing 'Assign additional columns from DataSrce' .
Can anyone please advise if this part of code can be rewritten in tsql or which other programming language ? probably for someone that knows VB and SQL Server. help much appreciated
Code:
'PROFILED SPEND ///////////////////////////////////////////////////////
'Assign worksheets to variables
Set wks1 = wkb1.Worksheets("ProfiledSpend")
Set Wks2 = wkb2.Worksheets("ProfiledSpend")
'Remove extraneous cells
If Wks2.Range("A1") <> "'Project" Then
Wks2.Columns("A").Delete
Wks2.Rows("1:20").Delete
End If
'Assign Data to Arrays
DataTrans = wks0.Range("Cost_Trans").Value
DataSrce = Wks2.Range("A1").CurrentRegion.Value
ReDim Data((UBound(DataSrce, 1) / Bse(5, 6)), 12) 'The number of Rows /Columns in the Profiled Spend table
'Row number assignment into Data() variable
k = 1
'Loop through data
For i = 1 To UBound(DataSrce, 1) Step 5
''Debug.Print i, DataSrce(i, 1)
'Assign known data - IDQ, ID and Qtr
Data(k, 1) = DataSrce(i, 2) & "-" & DataSrce(i, 4) 'IDQ
Data(k, 2) = DataSrce(i, 2) 'ID Number
Data(k, 3) = DataSrce(i, 4) 'Quarter
'Look up and assign spend data types
For j = 1 To UBound(DataTrans, 1) Step Bse(5, 6)
If DataTrans(j, 1) = DataSrce(i, 5) Then
Data(k, 4) = DataTrans(j, 3)
Data(k, 5) = DataTrans(j, 4)
Data(k, 6) = DataTrans(j, 2)
Exit For
End If
Next j
'Assign additional columns from DataSrce
Data(k, 7) = DataSrce(i, 8)
Data(k, 8) = DataSrce((i + 1), 8)
Data(k, 9) = DataSrce((i + 2), 8)
Data(k, 10) = DataSrce((i + 3), 8)
Data(k, 12) = DataSrce((i + 4), 8)
'Sum components for WLC total
Data(k, 11) = (DataSrce((i), 8) + DataSrce((i + 1), 8) + DataSrce((i + 2), 8))
Debug.Print i & ", " & k
Debug.Print Data(k, 1)
Debug.Print Data(k, 11), Data(k, 7), Data(k, 8)
k = k + 1
Next i
wks1.Activate
Add1 = wks1.Cells(WorksheetFunction.CountA(Range("A:A")) + 1, 1).Address
Add2 = wks1.Cells(((UBound(Data, 1)) + WorksheetFunction.CountA(Range("A:A"))), UBound(Data, 2)).Address
Addrss = Add1 & ":" & Add2
'Debug.Print Addrss, Add1, Add2
wks1.Range(Addrss).Value = Data
'Clear Arrays
Erase DataTrans
Erase DataSrce
Erase Data
Last edited: