Import CSV file and Archive it without ForEachLoop

jennifer zen 341 Reputation points
2020-10-15T09:24:51.487+00:00

Hi,

I have a csv file in a folder which needs importing to a table and then archive to another folder.

The SSIS package I have developed will first look for the file if it exists through a script task and then if exists, will proceed with truncate and load and then execute process task will move the file to archive.

The issue for me is at the load part... the name of the file will change every week and I want the connection string expression to just look for any .csv and process it-->@@[User::ToBeProcessed]+".csv"..But there is an error as invalid file as the file name is getting replaced by *.

Any suggestion please?

P.S not using foreachloop because there will be only one file to process and looping is not necessary at the moment.

Thanks in Advance :)

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,567 questions
{count} votes

Accepted answer
  1. jennifer zen 341 Reputation points
    2020-10-15T19:24:15.883+00:00

    Thanks you both for your help.

    I managed to get it done through script task. :)

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Vaibhav Chaudhari 38,726 Reputation points
    2020-10-15T09:36:51.503+00:00

    You could try to add a login in Script task, something like - if the file exists, then rename it to "InputFile.txt" and have this name hardcoded when you import data to table.


    Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav


  2. Monalv-MSFT 5,896 Reputation points
    2020-10-15T09:50:15.417+00:00

    Hi @jennifer zen ,

    May I know if these files have same structures?

    Please add an example value in variable [User::ToBeProcessed].

    Hope the following link will be helpful:

    Creating dynamically generated CSV files containing SQL Server data

    Best Regards,
    Mona

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.