I have a comma delimited text file that I import into SQL server 2008 using an SSIS package. As part of the package I have a derived column as part of the text file is an end date. THe problem I have is if there is no end date the text file has 00000000 instead of a real date such as 20130207. In my derived column editor I have the following expression which works fine for dates that arent all zero’s.
(DT_DATE)(SUBSTRING([Column 20],1,4) + "-" + SUBSTRING([Column 20],5,2) + "-" + SUBSTRING([Column 20],7,2))
Can anyone offer a solution or assistance on how best to handle the zeros?
Cause:
The Derived Column transformation is trying to convert the value
00000000to the date00-00-0000, which is not considered as a valid date value.Option 1: Database column allows NULL
If your database column is defined as
NULL, which means that it can accept NULL values, change the expression in theDerived Columntransformation as following:Option 2: Database column does not allow NULL
If your database column is defined as
NOT NULL, which means that it cannot accept NULL values, change the expression in theDerived Columntransformation as following: