question

paws27284 avatar image
paws27284 asked

SSIS 2005 Flat File Connection Manager

Hi ya'll! I am reading several flat files, using the flat file connection manager as the source, into an SSIS package in order to load them into a table. 2 of these files contain date columns. When I configure the columns on the advanced tab I use date{DT_DATE]. The date column in file 1 always contains a date and loads without issue. The date column in file 2 will contain blanks or a date and is always erroring out with a "Cannot Convert" issue. This error happens within the Flat file manager reading the file, it does not reach the destination task. I can always read it as a string, but I was hoping there was something I could do to fix the error instead of using an alternative. And Ideas? Thanks!
sql-server-2005ssis
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Martin Schoombee avatar image
Martin Schoombee answered
You could use a derived column transformation to check whether the field is empty or null, and return a NULL value of type DT_DATE. Your expression will look something like this: ISNULL(field) || field == "" ? NULL(DT_DATE) : (DT_DATE)field
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pavel Pawlowski avatar image Pavel Pawlowski commented ·
Yeah, if the data are not directly convertible into the DT_Date, then the data flow will fail. In that case as @Martin Schoo... suggested, ou can do the data type check and conversion in derived column transformation. But in that case you have to set the data type of the flat file column to a DT_STR or DT_WSTR so it can be red without error.
1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.