I am doing a data conversion where i need to pull many fields from a SQL2000 database to another SQL 2000 database. I am using DTS activeX scripts to perform this. During the transfer I will be pulling data from various length CHAR fields to VARCHAR fields. When the source CHAR field is blank, I wish to insert a NULL into the destination VARCHAR field. Because there are varying lengths and MANY fields I would like to simplify my code to do this. Currently I use this to make this conversion, which works but notice that I need to explicitly show how large the string is. I would like to simplify this.
****************
Function Main()
Select Case DTSSource("WK_CITY")
Case " "
DTSDestination("area_code") = NULL
Case Else
DTSDestination("area_code") = RTrim( DTSSource("WK_CITY"))
End Select
Main = DTSTransformStat_OK
End Function
****************
I received this idea from another help site but we could not get it to function correctly. the idea is to create a small function and then call that from the individual rows, then I would not need to know the length of the CHAR field and would not have to have all those different size " " string entries. Can anybody see what is wrong with this function and why it does not work? it parses correctly but does not populate the nulls only the data where it exists.
***********************
Function Main()
DTSDestination("area_code") = GetValue(DTSSource("WK_CITY"))
Main = DTSTransformStat_OK
End Function
Function Getvalue(Value)
If LEN(Value) THEN
GetValue = Value
Else
GetValue = Null
End If
End Function
******************************
Thanks for any help in advance.
****************
Function Main()
Select Case DTSSource("WK_CITY")
Case " "
DTSDestination("area_code") = NULL
Case Else
DTSDestination("area_code") = RTrim( DTSSource("WK_CITY"))
End Select
Main = DTSTransformStat_OK
End Function
****************
I received this idea from another help site but we could not get it to function correctly. the idea is to create a small function and then call that from the individual rows, then I would not need to know the length of the CHAR field and would not have to have all those different size " " string entries. Can anybody see what is wrong with this function and why it does not work? it parses correctly but does not populate the nulls only the data where it exists.
***********************
Function Main()
DTSDestination("area_code") = GetValue(DTSSource("WK_CITY"))
Main = DTSTransformStat_OK
End Function
Function Getvalue(Value)
If LEN(Value) THEN
GetValue = Value
Else
GetValue = Null
End If
End Function
******************************
Thanks for any help in advance.