SSIS: Start data load package for final table - sql-server

I have a daily 5 txt file in a Arrived folder, I'd like to design a SSIS package: each the txt file data load to stage then file goes to archive folder, if file not processing and load to stage then it will not goes archive, if all files load or not in stage this package job done. I have other package for stage to final table load but I want to make sure all files are load in stage then only this package run otherwise not run.
how I will design SSIS package?
Can somebody help me?

As there is dependency on package:files loading to Staging to package:staging to final table, it is better to make them as single SSIS package.
Define a Foreach Sequence Container, which processes the files.
On successful completion of the Foreach Sequence Container, you can have task for data load to destination.
Note: I have made the control flow simple. You need to have appropriate error logging to see the failed files and move them accordingly and successful files and move them accordingly.
Sample Reference code is given below:

Related

SSIS File System Task Doesn't Work but Reports Success

I created an SSIS package that extracts two files from a .zip file, imports data from them and then attempts to delete the files that were extracted.
The package works, data is imported and all tasks report success. However the File System Tasks that attempt to delete the files don't delete them, even though they report success.
I use the CozyRoc Zip Task to extract the files. When I remove the Zip Task, the File System Tasks actually do delete the files. I'm not certain that CozyRoc is causing the problem, but the existence of that task may be causing other issues with the package.
Can anyone help me figure out how to reliably delete the files?
Do I need to put in some sort of pause after the Data Flow Tasks to allow them to release whatever locks they might have on the files?
Is there a way to view the DOS commands that the File System tasks use at run time, to verify that they are actually attempting to delete the correct files?
Thank You,
Robbie
Control Flow:
Details:
Visual Studio 2019 v16.11.3
File Names are from Flat File Connection Managers (See image below).
Flat File Connection Managers use Expressions to set their connection strings.
The same connection managers are used to import the data, so I presume that they accurately refer to the correct files and their correct locations.
File System Task Editor for one of the delete tasks:

SSIS - Script task to create xlsx file (Export data from sql database to new excel file)

I have data flow task, which import data from sql server to excel. Currently it requires to have excel templated in place, meaning that I have xlsx file with column names without data in my network location. If I run the package the excel will be filled with data.
What is needed: If I run ssis package I need new xlsx file to be created every time if package is executed. So I need to just create xlsx file with define columns every time and the xlsx file name should include date.
I imagine that I have to set up script task before data flow task, which just creates xlsx file. I am not very familiar with C#, I hope that someone could share the code what to use to achieve this.
Or, you could create a folder and place a Template excel file with predefined format and no data.
Every time the process runs, it must:
Copy the file using File System task to the destination location
Use Data flow task to populate the data into the file in the Destination location
Rename the file in the Destination location as required

how to replace flat file created by a export data wizard on a schedule task with server agent

i already create a SSIS package on SSMS and scheduled in Server Agent, it create succesfully my '.csv' file but i want to overwrite the file every night when the scheduled job start again.
In your SSIS package, in the Flat File Destination, make sure the box Overwrite data in the file is checked. When the package runs each night, the file will be overwritten with new data.
Use a File System Task in your Control Flow.
The File System task performs operations on files and directories in
the file system. For example, by using the File System task, a package
can create, move, or delete directories and files. You can also use
the File System task to set attributes on files and directories. For
example, the File System task can make files hidden or read-only.

SSIS package import from file error handling

I'm trying to run a very simple SSIS package where I am dumping the contents of an Excel file into a database. The job is scheduled, but the file it is reading from is manually moved to the source location.
As it stands, if no one puts the Excel file in the staging area before the package runs the whole process fails.
Is there a way to not kill the job if the import file is missing? Maybe just log an error and try again later?
Thanks
An easy way to handle this is use a ForEach enumator and set a variable to the count of files in the folder. If the count is 0, gracefully exit out of the ForEach and set the precedence constraint accordingly.

SQL Server script to read many csv files at certain intervals and insert records

I have some csv files. I want to write SQL Server script to read the file at certain period and insert in SQL Server db, if record is not found and ignore it if file has already been read previously by scheduler. Each csv will contain one record only.
Like:
1.csv => John,2000,2012/12/12
2.csv => Tom,3000,2012/12/11
It will be great if someone can provide examples of script.
Thanks!
If I was you I would create an SSIS package that uses the multi file input. This input let's you pull data from every file in a directory.
Here are the basic steps for your SSIS package.
Check if there are any files in the "working" directory. If not end the package.
Move every file from your "working" directory to a "staging" directory.
You will do this so that if additional files appear in your "working" directory while you are in the midst of the package you won't lose them.
Read all of the files in the "staging" directory. Use a data flow with the multi file input.
Once the reading has been completed then move all of the files to a
"backup" directory.
This of course assumes you want to keep them for some reason. You could just as easily delete them from the "staging" directory.
Once you have your package completed then schedule it using SQL Server agent to run the package at whatever interval you are interested in.

Resources