I am importing address data from an older database into SQL 2000. The address is in the form of "Denver, CO 80014", I am trying to separate the address into three columns. My first step is to split the string at the "," and take the first part and make it the City. Then take the second element of the split string and take the last part as the Zip (I did this because the ZIP could be 80014-2112) The remaining part of the string is then the State. I am recieving the following error:
**********************************************************
Error Source: Microsoft Data Transformation Services (DTS) Data Pump
Error Description:Error Code: 0
Error Source= Microsoft VBScript runtime error
Error Description: Subscript out of range: '[number: 0]'
Error on Line 208
**********************************************************
The subscript it is refering to is the "asElements" index number, I have tried changing this and it only changes the '[number: 0]'
I have run this script in VB and it works like it is suppose to, but when I modify it for DTS it fails. What am I doing wrong.
Here is the DTS script:
'**********************************************************
' Address Break Down
'**********************************************************
Dim asElements
Dim sCity
Dim sState
Dim sZIP
Dim strTmp
Dim intI
Dim intP
' Split the string up at the 'comma'
asElements = Split(TRIM(DTSSource("CompTrustCitySt"
), ","
' If there aren't two elements discard all information
If UBound(asElements) < 1 Then
DTSDestination("CompTrustCity"
= Null
DTSDestination("CompTrustState"
= Null
DTSDestination("CompTrustZip"
= Null
End If
' Assign the first element (city) in the array
DTSDestination("CompTrustCity"
= TRIM(asElements(0))
' Assign the second element to a temp string
strTmp = TRIM(asElements(1))
intP = 1
' Set the length of the last part of the string to the space
For intI = Len(strTmp) To 1 Step -1
If Mid(strTmp, intI, 1) = " " Then
intP = intI + 1
Exit For
End If
Next
sZIP = Mid(strTmp, intP)
sState = UCase(Trim(Left(strTmp, intP - 1)))
' Validate Data
If Len(sZIP) = 2 And Len(sState) = 0 Then
sState = sZIP
sZIP = ""
ElseIf Len(sState) > 2 Then
sState = ""
End If
If Len(sZIP) <> 10 Then
If Len(sZIP) <> 5 Then
sZIP = ""
End If
End If
If IsNumeric(Left(sZIP, 5)) = False Then
sZIP = ""
End If
DTSDestination("CompTrustState"
= sState
DTSDestination("CompTrustZip"
= sZIP
Main = DTSTransformStat_OK
End Function
**********************************************************
Error Source: Microsoft Data Transformation Services (DTS) Data Pump
Error Description:Error Code: 0
Error Source= Microsoft VBScript runtime error
Error Description: Subscript out of range: '[number: 0]'
Error on Line 208
**********************************************************
The subscript it is refering to is the "asElements" index number, I have tried changing this and it only changes the '[number: 0]'
I have run this script in VB and it works like it is suppose to, but when I modify it for DTS it fails. What am I doing wrong.
Here is the DTS script:
'**********************************************************
' Address Break Down
'**********************************************************
Dim asElements
Dim sCity
Dim sState
Dim sZIP
Dim strTmp
Dim intI
Dim intP
' Split the string up at the 'comma'
asElements = Split(TRIM(DTSSource("CompTrustCitySt"
' If there aren't two elements discard all information
If UBound(asElements) < 1 Then
DTSDestination("CompTrustCity"
DTSDestination("CompTrustState"
DTSDestination("CompTrustZip"
End If
' Assign the first element (city) in the array
DTSDestination("CompTrustCity"
' Assign the second element to a temp string
strTmp = TRIM(asElements(1))
intP = 1
' Set the length of the last part of the string to the space
For intI = Len(strTmp) To 1 Step -1
If Mid(strTmp, intI, 1) = " " Then
intP = intI + 1
Exit For
End If
Next
sZIP = Mid(strTmp, intP)
sState = UCase(Trim(Left(strTmp, intP - 1)))
' Validate Data
If Len(sZIP) = 2 And Len(sState) = 0 Then
sState = sZIP
sZIP = ""
ElseIf Len(sState) > 2 Then
sState = ""
End If
If Len(sZIP) <> 10 Then
If Len(sZIP) <> 5 Then
sZIP = ""
End If
End If
If IsNumeric(Left(sZIP, 5)) = False Then
sZIP = ""
End If
DTSDestination("CompTrustState"
DTSDestination("CompTrustZip"
Main = DTSTransformStat_OK
End Function