SSIS SQL copy specific files to new folder

Posted on 2014-08-17
Last Modified: 2016-02-11
I need to create a SSIS package that looks at file names in a shared folder and compares it to a filename stored in a SQL table. If the filename in the shared folder = the filename in the SQL table I need it to copy only those files from the shared folder location to another location.  What SSIS task components should I be using to make this happen?
Thanks in Advance
Question by:GetRdone
    LVL 15

    Expert Comment


    Author Comment

    I don't see how a file system task alone can get this done. I have used this to copy a folder to another folder but I need the package to be more selective and only copy files that are listed in a *.txt or a SQL table that = the filename in the shared folder.
    so for example if my share folder has                                         and the SQL database file has
    001.jpg                                                                                              001.jpg

    I want only the 001.jpg copied to the new location.
    Thanks I hopes this explains what I'm trying to do better.
    LVL 14

    Accepted Solution


    You can use ForEach loop to fetch each file name and store the file name in the variable

    then in the Foreachloop use one execute sql task with select count(1) from table where columnname = @Variable

    and have the output to another variable

    Then while using the FileTask in the precedence constraints check the value of second variable if > 1 then do not perform otherwise perform

    This will move only the files which will not be available in the table

    Hope this will work

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    Over the last 2 years, I have been working on SSIS 2008. Really the tough tasks in SSIS are to deploy packages and pass parameters (Values from outside package). The latter is certainly a headache for developers, particularly for me. We had to ma…
    In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now