سؤال

I have a file to be loaded into SQL Server 2005 using SSIS 2005.

The file has a date field. The values are like '12/01/2010 16:38:51'.

Some of the rows in the file are wrong and will be redirected to a text file. But in the text file, the date will be changed to 2010-01-12 16:38:51 by SSIS.

Anyway to just redirect error rows to the text file without any modification?

هل كانت مفيدة؟

المحلول 2

I found if the output columns in the flat file error output of advanced editor of the flat file source is 'Flat File Source Error Output Column' (and the type of the column should be text stream [DT_TEXT] by default) then my problem is solved. This way, the flat file manager for the error output will automatically set the output columns to 'Flat File Source Error Output Column' and of type 'text stream [DT_TEXT]'. This is exactly what I wanted. SSIS treat the whole row as a single column of type 'text stream [DT_TEXT]' and just redirected. And this seems to be the default behaviour of SSIS. But in my original package, I somehow messed up and let each column from input mapped to a column in the error output. Then there was problem because SSIS was doing the date conversion things.

Anyway thanks for the help.

نصائح أخرى

You could always use a derived column and format the datetime using the parts of the date.

(DT_WSTR, 20) (DT_WSTR, 2) RIGHT("0" + (DT_WSTR,2)MONTH(<DATE_IN_QUESTION>),2)  + "/" + 
(DT_WSTR, 2) RIGHT("0" + (DT_WSTR,2)DAY(<DATE_IN_QUESTION>),2) + "/" + 
(DT_WSTR,4)YEAR(<DATE_IN_QUESTION>) + " " + 
(DT_WSTR, 2)DATEPART( "Hh", <DATE_IN_QUESTION>) + ":" +  
(DT_WSTR, 2)DATEPART( "mi", <DATE_IN_QUESTION>) + ":" +  
(DT_WSTR, 2) RIGHT("0" + (DT_WSTR, 2)DATEPART( "ss", <DATE_IN_QUESTION>),2)    
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top