0

I am using SSIS to fetch data from a .CSV file and upload it into SQL Server 2012.

I am able to upload the data but now I have a date column in SQL Server and I have timestamp in .csv file name.

I would like to extract the date only (e.g. 2015-08-17) from the .csv file name and then add that to date column in SQL Server after data is imported.

Example file name: TC_001_Feature_20150814_000132

Value need: 20150814 and added it in SQL Server column as 2015-08-14.

5
  • 1
    You can do it with a script task that parses the file name and populates a variable with the date value, and then add it as a derived column to your dataflow, or update the date column in sql with a sql task. Commented Aug 17, 2015 at 13:54
  • Thanks for the prompt response, would you be able to provide a sample script that would parse the file name for data value. Commented Aug 17, 2015 at 13:58
  • No I don't have a pre-written script handy. I'm sure if you google "string parsing" in the script language of your choice, you will find examples. Commented Aug 17, 2015 at 13:59
  • Break your problem down into smaller parts until you get to the level where you can solve it. Commented Aug 17, 2015 at 13:59
  • I'm going to close this as a duplicate. In the linked answer, you'll see two different ways of adding the current file name into the data flow as a column. Then you'll need to use the substring to slice out the date part of the string, via a derived column. Then another derived column will allow you to convert the text date into an actual date. Commented Aug 17, 2015 at 14:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.