Sunday, February 26, 2012

error with datetime datatype

Hi Guys,

I'm having problem in loading textfile into the database. One of the columns in the textfile has a datetime datatype.

Here is a sample of the text file. All the other columns are string except for the datetime: "5/4/2006"

"1","1","ITEM","5/4/2006","10:05:04","11110",10004,"Regular Half Chicken",1,130.00,0,0

Error is shown below.

Error: 0xC0202009 at Data Flow Task, OLE DB Destination [154]: An OLE DB error has occurred. Error code: 0x80004005.

An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Invalid character value for cast specification".

Error: 0xC020901C at Data Flow Task, OLE DB Destination [154]: There was an error with input column "Transaction_Date" (1233) on input "OLE DB Destination Input" (167). The column status returned was: "The value could not be converted because of a potential loss of data.".

Error: 0xC0209029 at Data Flow Task, OLE DB Destination [154]: The "input "OLE DB Destination Input" (167)" failed because error code 0xC0209077 occurred, and the error row disposition on "input "OLE DB Destination Input" (167)" specifies failure on error. An error occurred on the specified object of the specified component.

Error: 0xC0047022 at Data Flow Task, DTS.Pipeline: The ProcessInput method on component "OLE DB Destination" (154) failed with error code 0xC0209029. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.

Error: 0xC0047021 at Data Flow Task, DTS.Pipeline: Thread "WorkThread0" has exited with error code 0xC0209029.

Please help!!!

Thanks in advance,

Larry

You'll need to throw a "convert" into the dataflow to convert that date format:

select convert(datetime, '10/31/2006',101) 'returns 2006-10-31 00:00:00
select convert(datetime, [Transaction_Date],101)

No comments:

Post a Comment