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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user5235510
  • 23
  • 1
  • 8
  • 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. – Tab Alleman Aug 17 '15 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. – user5235510 Aug 17 '15 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. – Tab Alleman Aug 17 '15 at 13:59
  • Break your problem down into smaller parts until you get to the level where you can solve it. – billinkc Aug 17 '15 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. – billinkc Aug 17 '15 at 14:38

0 Answers0