Load file using SSIS if Exists in source folder else stop the process

Bala Narasimha Challa 466 Reputation points
2020-10-21T05:28:56.773+00:00

Hi Team,
Have a one requirement like bellow.
My team placing a one excel file in folder and need to upload into data base. Before loading data need to check either file is exists or not.
If exists load data into DB else stop the process.

Please help on this.

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

3 answers

Sort by: Most helpful
  1. Vaibhav Chaudhari 38,736 Reputation points
    2020-10-21T05:32:34.973+00:00

    There is a blog on this. See if that helps - http://www.techbrothersit.com/2013/07/ssis-how-to-check-if-file-exists-in.html


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

    0 comments No comments

  2. Monalv-MSFT 5,901 Reputation points
    2020-10-21T06:26:56.797+00:00

    Hi @Bala Narasimha Challa ,

    Please use Script Task to check if the file exists in ssis package.

    Hope the following links will be helpful:

    Check if file exists in SSIS

    Check if file exists in folder or not (SSIS, SDT 2015 and SQL 2016)

    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.


  3. Ramana Kopparapu 306 Reputation points
    2024-09-29T11:28:47.43+00:00

    Create two variables FilePath with value including extension of file

    and IsFileExists with Int 0 value

    Drag ST and select FilePath as ReadOnlyVariable and IsFileExists as ReadWriteVariable

    Add System.IO

    string filepath = Dts.Variables["User::FilePath"].Value.ToString();

            if(
    
                File.Exists(filepath)
    
                )
    
            {
    
                Dts.Variables["User::IsFileExists"].Value = 1;
    
                MessageBox.Show("Yes!!File Exists!");
    
            }
    
            else
    
            {
    
                MessageBox.Show("No!!File Does Not Exists");
    
            }          	
    

    Drag DFT and Connect with ST and write an expression on Precendence Constraint

    @IsFileExists==1 and Test your connection..

    Load Txt file in DFT to OLEDB Dest table.

    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.