开发者

How to convert a timestamp in string format to datetime data type within a package?

Could someone guide me on how to convert 开发者_运维问答MM/DD/YYYY HH:MM that comes from a flat file source as a string to a datetime to a ole db destination using the derived column.

This is my flow.

Flatfile -> Data Coversion -> Derived Column


There are couple of ways to achieve this. You can use the Derived Column transformation to convert the value or you can declare the flat file column on the Flat File Connection as column of data type database timestamp [DT_DBTIMESTAMP]. Steps 1 - 8 describes the first option and step 9 describes the second option.

Step-by-step process:

  1. This example uses the flat file named Source.txt shown in screenshot #1.

  2. Flat File Connection is configured as shown in screenshots #2 and #3.

  3. Data Flow Task is configured as shown in Screenshot #4.

  4. Flat File Source is configured as shown in Screenshot #5.

  5. Derived Transformation task is configured as shown in screenshot #6 using the type cast DT_DBTIMESTAMP to convert the string value to date time value.

  6. OLE DB Destination is configured as shown in screenshot #7.

  7. Screenshot #8 displays the sample package execution.

  8. Screenshot #9 displays the data in the SQL table after the package execution.

  9. another easier way to do this to declare the column that contains the date time value as data type database timestamp [DT_DBTIMESTAMP] as shown in screenshot #10. This way you don't need a Derived Column Transformation and the Data Flow Task will be as shown in screenshot #11. You can directly map the Flat File columns to the OLE DB destination columns.

Hope that helps.

Screenshot #1:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #2:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #3:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #4:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #5:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #6:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #7:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #8:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #9:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #10:

How to convert a timestamp in string format to datetime data type within a package?

Screenshot #11:

How to convert a timestamp in string format to datetime data type within a package?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜