Scenario:
We get multiple files during a day and night. we have scheduled to run our SSIS Package every hour. We want to create a Zip file per day and then keep adding the files to it after loading in the same day. Next day a new Zip file should be automatically created and files should be copied to that after loading.
Solution:
In this video we will learn the solution for our scenario " How to Create A Zip File with Date Per day and add files to it after loading in SSIS Package". Below are the list of items we will learn in this video
- How to Create Package Parameters for InputFolder and ArchFolder so we can change the values of them according to the environment ( QA, UAT, Prod) and we don't have to make any changes in the SSIS Package.
- How to use Foreach Loop Container to look through files in SSIS Package
- Save File name in FileName Variable From Foreacah Loop Container
- How to Change .NET Framework 4 to 4.5
- How to add reference to Assemblies such as System.IO.Compression and System.IO.Compression.FileSystem
- Create empty Zip File by using Script Task
- Add file to Zip file by using Script task in SSIS Package
Script used in Script Task to Create Zip file with Date and Add Files to Zip File in SSIS Package
public void Main() { //Assign values to local variable from SSIS Package Parameters and Variables string zipfile = Dts.Variables["User::ArchFullPath"].Value.ToString(); string ArchFolder = Dts.Variables["$Package::ArchFolder"].Value.ToString(); string filename = Dts.Variables["User::FileName"].Value.ToString(); string inputfilepath = Dts.Variables["$Package::InputFolder"].Value.ToString() + filename; //If zip File already exist for the same day, just add the files to it if ( File.Exists(zipfile)) { MessageBox.Show(" Zip File does Exists"); using (ZipArchive addfile = ZipFile.Open(zipfile, ZipArchiveMode.Update)) { addfile.CreateEntryFromFile(inputfilepath, filename); File.Delete(inputfilepath); } //If zip file does not exist for the day, create it and add files to it } else { MessageBox.Show("File Does not exists"); var fileStream = new FileStream(zipfile, FileMode.Create); fileStream.Close(); using (ZipArchive addfile = ZipFile.Open(zipfile, ZipArchiveMode.Update)) { addfile.CreateEntryFromFile(inputfilepath, filename); File.Delete(inputfilepath); } } Dts.TaskResult = (int)ScriptResults.Success; }
Expressions for ArchFullPath Variable:
@[$Package::ArchFolder]+Replace(Substring((DT_WSTR,30)GEtdate(),1,10),"-","_")+".zip"
How to Create Zip File and Add Files to It in SSIS Package by using Script Task- SSIS Tutorial
Related Posts/Videos on Zip / UnZip by Script Task
- How to change .NET Framework version in Script Task and Add Reference to Assembly(ZipFile Demo)
- Load Text Files,Zip them to Folder with Datetime and Delete From Input Directory in SSIS Package
- Extract Files From Zip Files and Delete the Zip Files once Unzipped in SSIS Package
- Load File/s, Zip and Delete from Source Folder in SSIS Package
- Zip ( Compress) Files and Add them to Folder According to Extension in SSIS Package
- Zip or Compress Files according to the Name of Files in SSIS Package
- Get File names from Zip Files and Insert into SQL Server Table in SSIS Package
- How to Zip ( Compress) Multiple Folders and Delete in SSIS Package
Hi Sir,
ReplyDeleteCould you please create a post which will convert csv file to password protected using ssis
Regards,
Anmol
Welcome To Techbrothersit: Create Zip File With Date And Keep Adding Files To It After Loading For The Same Day In Ssis Package - Sql Server Integration Services(Ssis) Package >>>>> Download Now
Delete>>>>> Download Full
Welcome To Techbrothersit: Create Zip File With Date And Keep Adding Files To It After Loading For The Same Day In Ssis Package - Sql Server Integration Services(Ssis) Package >>>>> Download LINK
>>>>> Download Now
Welcome To Techbrothersit: Create Zip File With Date And Keep Adding Files To It After Loading For The Same Day In Ssis Package - Sql Server Integration Services(Ssis) Package >>>>> Download Full
>>>>> Download LINK Hr
This comment has been removed by the author.
ReplyDeleteNormally, presumed file transfer specialist co-ops acknowledge installment through Visa or Paypal.transfer files
ReplyDeleteI know this is one of the most meaningful information for me. And I'm animated reading your article. But should remark on some general things, the website style is perfect; the articles are great. Thanks for the ton of tangible and attainable help. convert pdf to png
ReplyDeleteThis particular is usually apparently essential and moreover outstanding truth along with for sure fair-minded and moreover admittedly useful My business is looking to find in advance designed for this specific useful stuffs… video upload
ReplyDeleteNice to be visiting your blog once more, it has been months for me. Well this article that ive been waited for therefore long. i want this article to finish my assignment within the faculty, and it has same topic together with your article. Thanks, nice share. 먹튀사이트
ReplyDeleteSomeone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers! 카지노사이트검증
ReplyDeleteThankyou for this wondrous post, I am glad I observed this website on yahoo. 토토사이트
ReplyDeleteCool stuff you have got and you keep update all of us. 먹튀검증업체
ReplyDeleteThank you for taking the time to publish this information very useful! 88카
ReplyDeleteThis is an impressive post. Come here and take a look at my information.
ReplyDeleteThis information was very useful. I was impressed by the polite posting.
사설검증업체
Hello. We provide helpful information in your life. Take a look and go.
ReplyDeleteThis is an impressive post. Come here and take a look at my information.
먹튀폴리스 검증업체
This information was very useful. I was impressed by the polite posting.
ReplyDeleteHello. We provide helpful information in your life. Take a look and go.
먹튀헌터
Thank you so much for such a well-written article. It’s full of insightful information. Your point of view is the best among many without fail.For certain, It is one of the best blogs in my opinion. textbook answers
ReplyDeleteI’m thinking some of my readers might find a bit of this interesting. Do you mind if I post a clip from this and link back? Thanks 안전놀이터
ReplyDeleteWhat I was thinking about was solved thanks to your writing. I have written on my blog to express my gratitude to you.토토사이트My site is We would be grateful if you visit us.
ReplyDeleteWhile looking for articles on these topics, I came across this article on the site here. As I read your article, I felt like an expert in this field. I have several articles on these topics posted on my site. Could you please visit my homepage? 오공슬롯
ReplyDeleteThanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing... Satta king
ReplyDeleteWelcome To Techbrothersit: Create Zip File With Date And Keep Adding Files To It After Loading For The Same Day In Ssis Package - Sql Server Integration Services(Ssis) Package >>>>> Download Now
ReplyDelete>>>>> Download Full
Welcome To Techbrothersit: Create Zip File With Date And Keep Adding Files To It After Loading For The Same Day In Ssis Package - Sql Server Integration Services(Ssis) Package >>>>> Download LINK
>>>>> Download Now
Welcome To Techbrothersit: Create Zip File With Date And Keep Adding Files To It After Loading For The Same Day In Ssis Package - Sql Server Integration Services(Ssis) Package >>>>> Download Full
>>>>> Download LINK wT