Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Active X + DTS

Author  Topic 

slboytoy
Starting Member

30 Posts

Posted - 2004-11-18 : 17:36:30
I am in charge of the front end of SQL for my business, but I did some DTS design for the first time, and want to see if anyone can tell me I'm doing it wrong, or how i could make it faster, make it better..

Here is the background, the table off the main frame, has the Company ID, then 500, 503, 403, 600, 543, (etc...) for column names. Those numbers are products. Now if the company has that product, there is an 'X' in the field. So a record would look like...

Company_500_503_403_600_543_
111111___X___X_______X______
222222___X___X___X__________
555555___________________X__

Now that is a horrible way to design a table, since product codes will come and go (thus changing column names)...

So I've created a table like this...
Company_Product
111111______500
111111______503
111111______600
222222______500
222222______503
222222______403
555555______543


Now am I doing this right? I have a DTS package, with an Active X script instead that looks like this..

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()

' These values were copied from the ADOVBS.INC file.
'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'---- CommandTypeEnum Values ----
Const adCmdUnknown = &H0008
Const adCmdText = &H0001
Const adCmdTable = &H0002
Const adCmdStoredProc = &H0004

Dim oFSO 'Text File Source
Dim oFile 'Text File
Dim i, y, x
Dim ColumnName 'Array of Column Names
Dim DataLines() 'Array of each line of data

' Instantiate the ADO objects.
set myConn = CreateObject("ADODB.Connection")
set myRecordset = CreateObject("ADODB.Recordset")

myConn.Open "Provider=SQLOLEDB.1;Data Source=PCMCSQL;" & _
"Initial Catalog=DataWarehouse;User Id=dwintranet;Password=molsoncanadian;"

' instantiate the Scripting Object
set oFSO = CreateObject("Scripting.FileSystemObject")

' Open the file
set oFile = oFSO.OpenTextFile("\\Hydlna01\downloads\SQLDWN\FPMMATXU.TXT")

' store the first line, which is the ProductCode Names, in a global variable
' DTSGlobalVariables("StartDate").value = x.Readline
ColumnName = Split(oFile.Readline, "\")

' MsgBox "The Start Date is: " & DTSGlobalVariables("StartDate").value
' MsgBox ColumnName(0)

i = 0
Do While not oFile.AtEndOfStream
ReDim Preserve DataLines(i)
DataLines(i) = oFile.Readline 'Each line of data put into array
i = i + 1
Loop

oFile.Close
' Good practice to setobject variables to nothing
Set oFSO = Nothing
Set x = Nothing


' store the second line, which is the End Date, in a global variable
' DTSGlobalVariables("EndDate").value = x.Readline
' DataLine = Split(x.Readline, "\")
' MsgBox "The End Date is: " & DTSGlobalVariables("EndDate").value
' MsgBox DataLines(2)


strSQL = "Delete DataWarehouse.dbo.MattMatrix"
myRecordset.Open strSQL, myConn, adOpenKeyset

For x = 0 To UBound(DataLines) Step 1
Data = Split(Trim(DataLines(x)), "\")
For i = 3 To UBound(Data) Step 1
If Data(i) = "X" Then
Data(i) = ColumnNames(i)
End If
Next

For y = 3 To UBound(Data) Step 1
If Data(y) > " " Then
strSQL = "INSERT INTO DataWarehouse.dbo.MattMatrix (SoldToCustomerNumber, ShipTo, CustomerType, ProductCode) Values ('" _
& Data(0) & "', '" & Data(1) & "', '" & Data(2) & "', '" & Data(y) & "') "
myRecordset.Open strSQL, myConn, adOpenKeyset
End If
Next
Next

Main = DTSTaskExecResult_Success
End Function


So I am going from 800 records, to oer 40000 records. When running the active X, it takes over 5 minutes to do this. Is that alright?
   

- Advertisement -