conevrting NULL String COLUMNS FROM FLAT FILE SOURCE TO DATETIME AND INT TYPE in Destination table
I am importing flat file source to table, all my flat file columns are string datatype. And few of my columns are NULL values, where as in my destination tables those are Datetime and Int type. I tried to use derived column and Data conversion transformation
but failed to load.
my source columns
todays date yesterday date batchno
NULL NULL NULL
todaysdate column and yesterday date column in destination table is Datetime and Batchno column is int type. I tried suing derived and data conversion transformations but it is failing.
I need to load Null values into destination for this columns.
June 9th, 2012 7:19am
Try to set the expression for the derived column to something like:
TRIM([YOURSTRINGFIELD]) == "NULL" ? NULL(DT_NUMERIC, precision, scale) : (DT_NUMERIC, precision, scale)[YOURSTRINGFIELD]
Free Windows Admin Tool Kit Click here and download it now
June 9th, 2012 9:03am
Does your source file actually contain the string "NULL" ? I suspect you are just using that to illustate your point, in that case use the Derived Column Transformation, and the expressions:
LEN(TRIM([todays date])) == 0 ? NULL(DT_DBTIMESTAMP) : (DT_DBTIMESTAMP)[todays date]
LEN(TRIM([yesterday date])) == 0 ? NULL(DT_DBTIMESTAMP) ? (DT_DBTIMESTAMP)[yesterday date]
LEN(TRIM(batchno)) == 0 ? NULL(DT_I4) : (DT_I4)batchno
If your source file does actually contain "NULL" replace the LEN(...) expressions with TRIM([todays date]) == "NULL" and so on.
June 9th, 2012 1:58pm