How to check particular File exists in Folder in SSIS without using Script Task Or Script Component?

Ramana Kopparapu 306 Reputation points
2024-08-03T14:21:46.4733333+00:00

main aim to get output without using #C and VB code... Is it possible?

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

2 answers

Sort by: Most helpful
  1. Ahad Karimi Moridani 80 Reputation points
    2024-08-03T17:51:59.3033333+00:00

    Yes, use the File System Task in SSIS. Configure it to check for file existence and set its result to a variable.
    User's image

    0 comments No comments

  2. ZoeHui-MSFT 41,491 Reputation points
    2024-08-05T03:32:01.44+00:00

    Hi @Ramana Kopparapu,

    • Create a Variable containing the path where the file resides. Example User::filepath
    • Create another variable to save the actual file found on the Foreach loop, example User::filename
    • Add the Foreach Loop from the SSIS Toolbox.
    • On the Foreach Loop editor, on Collection left tab select in Enumerator - Foreach File Enumerator
    • Click Expressions and add one for Property Directory and select in the expression the @[User::filepath]
    • Enter on the Folder the value of the filepath variable (this will be overridden at execution from the Expression above, this is if you filepath is changed at runtime)
    • On file enter something like . or *.txt or whatever filter you want to apply to the folder.
    • On the Variable Mappings left tab select on the Variable column the User::filename variable, the Index column will default to 0.
    • Then put your logic inside the Foreach Loop box.

    This will only execute your logic if a file is found. You can also use this to process multiple files if they exist on the folder.

    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.