Skip to main content

SSIS_File Existance Check and then moving the file to a folder with timestamp.

 To check where the folder has file or not ,i am going to use Script Task (.NET)


For using the Script task we create few variables.


Post Creating the Variable , Copy and paste the below code into the script task.


//Declare a variable

   string x;

//Assign the value to variable

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

//Check whether file exists or not

//If exists return TRUE else FALSE

  Dts.Variables["User::FileExists"].Value = File.Exists(x);


The code simply takes the the X variable as the path and File.Exits(x) checks whether the file exists in the Folder path mentioned or not.

Add the below Library.


Save and Build the code.


Now we will write a expression in the Precedance constraint.



IF the File is not there, then you are supposed to log.





Now to move the file from one folder to another with timestamp , we do more changes to the above package.


we add 2 more variables,




 @[User::ArchiveFolder]+"\\"+"Emp_"+ Replace (Replace (Replace (Substring ((DT_WSTR, 50) Getdate(), 1, 19), "-", ""), ":", "")," ", "_")+".txt"


Creating a Variable Filepath:

We can simply go to the Connection string properties.




Tomorrow when you want to change the file path , you go and change in the Filepath varaible.






Popular posts from this blog

Introduction to Datawarehouse

In shot what is DWH (Data warehouse)? A DWH is a Large Database which consists of Dimension and Fact tables. Or Collection of DataMart is called as a DWH. Father of Data Warehouse: Dr. William H. Inmon Dr. Ralph Kimball -Introduced Dimension Modelling to design DWH in 1990. What is Data Warehouse? As per Dr. William Inmon, Data Warehouse is a -       Subject Oriented (Loans, Mutual Funds etc.) -       Integrated (Get data from various sources) -       Time Variant (Different time period data)   ·          *Datamart is Subject Oriented ·          *DWH is a collection of Datamart ·          *DWH is a superset of Datamart ·          *Datamart is also another database. Top-down Approach: (DWH->Datamarts)   ...

DBMS

Database : database can be defined as a collection of information stored at a particular place written in a predetermined manner, belongs to a particular topic.  DBMS: (DATA BASE MANAGEMENT SYSTEM):  it is defined as software which is present inside the database which is used o maintain or manage the data within the database .                                 In the above diagram, if the user needs any info from the database. He has to contact with  dbms , then the dbms goes to the database, takes the information from the  database and gives it back to the user. Database models :  these models are broadly divided into the following types: 1.         FMS/FDMS 2.         HMS/HDMS 3.         NDBMS 4.         RDBMS 5.      ...

About Me

I am a Data Analyst /Azure Data Engineer with more than 4 years of full-time work experience and around 3.4+ years of experience in different Microsoft Technologies ( Azure Data Factory , Azure SQL, Azure Data lake Gen 2).  I currently work mainly with Azure SQL server, Power bi / Tableau ,Azure Data Factory, Azure SQL, T-SQL, Blob Storages as well as XML and working on Development and Deployment.  My Technical skills are Azure SQL, Power Bi, Tableau ADLS,  Azure Data Factory,    SSIS, SSRS. Keywords Relevant to me : • Business Intelligence Developer • Data warehouse Developer •   Data Analyst • Azure Data engineer I like Learning new Tech, so in free time i explore learning about tech , taking courses on Digital Platforms and attending online workshops. I like Singing and Cycling as my hobby. If you want to get in touch, find me at 'Gauravthamada gmail com'