![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi all, This is my first time posting, as well as my first time using DTS. I find myself in a bit of a quandary. I'm trying to import data from a flatfile into a SQL database, using the ActiveX VBscript engine. I want the fields which are nothing but spaces to be true 'null' values in SQL. I'm using a function which sets any field which contains nothing but spaces equal to "" (empty string). In the case of the numeric fields, this works perfectly. However, the char and varchar field types seem to insert an empty value, but not a null. I've got the checkbox for 'keep null values' turned on. How would I go about inserting a null value into these fields? Any help would be greatly appreciated. Thanks in advance, ~Gary |
#3
| |||
| |||
|
|
if( Trim( DTSSource("ColumnSource")) = "") then DTSDestination("ColumnDestination") = null end if I've got something similar (Created a function as I'd be doing this on every |
#4
| |||
| |||
|
|
Davide wrote: if( Trim( DTSSource("ColumnSource")) = "") then DTSDestination("ColumnDestination") = null end if I've got something similar (Created a function as I'd be doing this on every field save 2 or 3). I've listed the code below. I'm not sure what's causing it to not like to insert an actual null on alpha fields, though. Function TrimNullIf(SourceString, IfNull) If trim(SourceString) = null Then TrimNullIf = IfNull Else TrimNullIf = trim(SourceString) End If End Function And it is being called like so: DTSDestination("S2_Agency") = TrimNullIf(DTSSource("Col002"),null) |
![]() |
| Thread Tools | |
| Display Modes | |
| |