简体   繁体   中英

SQL Server data tools derived column

My SQL teacher converted an Excel file to a .csv file

My problem is that the .csv file has changed the date values ( dd-mm-yy ) to strange numbers. This is a big problem because my SQL Server database needs a date value not a strange number + characters. I am using SISS to solve this problem, but I don't know how to fix it. I am quite new to SSIS.

Date example in CSV: 41640

Date example in SSIS dataviewer: 1;1;41640;41641;41646 (strange code instead of a date)

My SQL teacher says that we must use a derived column for this problem, he was also talking about the Pivot and the Unpivot tools. Can you guys be so kind to give us some examples how to solve this with a derived column?

I can't post any images to make it more clear what a mean. Because I need 10 reputation to post images :(

I am using the flat file source to call my .csv , then I have placed a empty derived column (to solve the .csv date problem). After that I have a Date conversion, followed by a derived column (used to TRIM the new data)

I hope that you guys can help me out!

You need to ad a step adding derived or calculated columns. In the column that contains eg 41640 I will assume that column name is xyz.

The new calculated column will use the formula DateAdd(DD, [xyz], '31 Dec 1899') and be a DT_DATE type.

For excel, a date od 1 Jan 1900 is represented by the number 1. So you need to convert these numbers to a date. I'm not 100% sure of the formula syntax as I don't have SSIS on this machine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM