Check File Existence in SSIS with Ease

26 July 2021
KingswaySoft Team

It is not uncommon that you run into the requirement that you have to check whether a particular file exists before starting the ETL process that imports the data. There is no straightforward solution to implement this in SSIS except writing your own C# code using a Script component. We recognize the challenges faced by developers in working with such requirement, so we create this blog post to show you how to achieve this in SSIS without writing a single line of code by leveraging the Premium File Properties Task offered in the KingswaySoft SSIS Productivity Pack.

Premium File Properties Task is a control flow component that can be used to read file properties or update file properties. It supports various types of connections including Local File, SFTP, FTPS and cloud storage services like Amazon S3, Google Cloud Storage, etc. If you want to learn more about the component, you may click here for the detailed information of the component.

Checking file existence in SSIS can be extremely easy using the KingswaySoft Premium File Properties Task, all it requires is merely a few mouse clicks. Simply drag and drop the component into the package and open the component, specify the Connection Manager, Source Path and Read File Properties action, add “SourcePathExists” Boolean type property to the Property Output Mapping grid and provide a Boolean type variable to store the file existence check result.

Image 001 - Premium File Properties Task - Source Path Exists

The screenshot above shows an example of checking file existence at local file system path “D:\SampleFile.csv”. If the file exists at the specified file path, a True value will be assigned to the specified user variable, otherwise the False value will be assigned.

After configured the Premium File Properties Task component, next, we can use expression in SSIS Precedence Constraint to only execute the next task once the expression is evaluated to True.

Image 002 - SSIS precedence constraints menu

Right click on precedence link between two control flow tasks to open the context menu, choose Edit to open the precedence constraints editor:

Image 003 - SSIS precedence constraints setting

The expression “@[User::BooleanVariable]==true” is used in SSIS Precedence Constraint Expression, which checks if the file path existence result value stored in @[User::BooleanVariable] variable is equal to True.

The overall Control flow design of the package is shown in the screenshot below, as you may notice, there's a small fx icon next to the constraint, this indicates that the constraint is evaluating expressions.

Image 004 - File Existence Package Design

Let’s execute our package to test the package design, the following screenshot is taken when the file doesn’t exist:

Image 005 - Execute Package when File not Exist

You can see that only the Premium File Properties Task runs, but the Process File data flow task does not.

The below screenshot confirms that the Process File data flow is executed when the specified file path exists. 

Image 006 - Execute Package when File Exists

We hope you find this article helpful. Please feel free to let us know if you have any further comments or suggestions.

Archive

November 2024 3 October 2024 1 September 2024 1 August 2024 2 July 2024 1 June 2024 1 May 2024 1 April 2024 2 March 2024 2 February 2024 2 January 2024 2 December 2023 1 November 2023 1 October 2023 2 August 2023 1 July 2023 2 June 2023 1 May 2023 2 April 2023 1 March 2023 1 February 2023 1 January 2023 2 December 2022 1 November 2022 2 October 2022 2 September 2022 2 August 2022 2 July 2022 3 June 2022 2 May 2022 2 April 2022 3 March 2022 2 February 2022 1 January 2022 2 December 2021 1 October 2021 1 September 2021 2 August 2021 2 July 2021 2 June 2021 1 May 2021 1 April 2021 2 March 2021 2 February 2021 2 January 2021 2 December 2020 2 November 2020 4 October 2020 1 September 2020 3 August 2020 2 July 2020 1 June 2020 2 May 2020 1 April 2020 1 March 2020 1 February 2020 1 January 2020 1 December 2019 1 November 2019 1 October 2019 1 May 2019 1 February 2019 1 December 2018 2 November 2018 1 October 2018 4 September 2018 1 August 2018 1 July 2018 1 June 2018 3 April 2018 3 March 2018 3 February 2018 3 January 2018 2 December 2017 1 April 2017 1 March 2017 7 December 2016 1 November 2016 2 October 2016 1 September 2016 4 August 2016 1 June 2016 1 May 2016 3 April 2016 1 August 2015 1 April 2015 10 August 2014 1 July 2014 1 June 2014 2 May 2014 2 February 2014 1 January 2014 2 October 2013 1 September 2013 2 August 2013 2 June 2013 5 May 2013 2 March 2013 1 February 2013 1 January 2013 1 December 2012 2 November 2012 2 September 2012 2 July 2012 1 May 2012 3 April 2012 2 March 2012 2 January 2012 1

Tags