How to store file names in SQL Server Table by using SSIS Package

Scenario:

In this blog post we are going to learn how to read the file name from a Folder and Sub Folders and insert into a SQL Server Table. This can be helpful for Audit and to know how many files we have in folders.

Solution:

We will be using For-each loop container to get the files information. Let's start step by step 

Step 1:

To save the file name we need to have a SQL Server table. Let's create a SQL Server table by using below script.

CREATE TABLE dbo.FileInformation
  (
     FileID   INT IDENTITY(1, 1),
     FileName VARCHAR(250)
  )

Step 2:

Create an SSIS Package by using BIDS or SSDT. Create a variable as shown below that is holding your files and also have sub folders with files.

Fig 1: Create FolderPath variable in SSIS Package

FileNamewithPath variable will be used in Foreach Loop Container to hold the value of file name with path that we will insert into our SQL Server table.

 Step 3:

Drag For-each loop container from SSIS Toolbox on Control Flow Pane and configure as shown below. If you are only interested to save file name then use Name only and if you are interested to save file name with extension then use Name and Extension. As I want to save file name with folder , I have chosen Fully qualified in #5.
Fig 2: Configure Foreachloop Container to read the file names with path

Map the value read by Foreach loop container to FileNamewithPath varible.
Fig 3: Map the value to Variable in Foreach loop container

Step 4:

Create OLE DB Connection to the database where you have created dbo.FileName table.

Step 5:

As now we can read the file name with path by using Foreach loop and values will be saved in variable for each iteration , we can save the value of variable in our SQL Server Table. To save the variable value in SQL Server Table, we can use Execute SQL Task. Bring the Execute SQL Task inside the Foreach Loop container and configure as shown below.

 Fig 4: Configure Execute SQL Task to insert variable value in SQL Server Table in SSIS Package


Map the variable to Execute SQL Task insert statement.
Fig 5: Map variable in Execute SQL Task in SSIS Package


Output:

Our package is ready. Let's run our SSIS Package and see if the file names are saved in SQL Server table from folder/s.

 Fig 6: SSIS Package to load file names from folder/s in a SQL Server Table


Output from SQL Server Table
 Fig 7: File Names in SQL Server table stored by SSIS Package

As we can see that the file names with folder information is successfully inserted in SQL Server table.


Video Tutorial for this post

37 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information. Keep it up. Keep blogging. Looking forward to reading your next post.
    Best Wedding Photographers | Wedding Photographers in Rohini | Wedding Photographers in Pitampura | Wedding Photographers in Delhi

    ReplyDelete
  3. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    Thanks...
    web development company sydney

    ReplyDelete
  4. This article is an appealing wealth of informative data that is interesting and well-written. I commend your hard work on this and thank you for this information. You’ve got what it takes to get attention.WordPress Plugins

    ReplyDelete
  5. I am incapable of reading articles online very often, but I’m happy I did today. It is very well written, and your points are well-expressed. I request you warmly, please, don’t ever stop writing. where to buy cbd

    ReplyDelete
  6. What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. what is cbd vape oil

    ReplyDelete
  7. Wonderful article. Fascinating to read. I love to read such an excellent article. Thanks! It has made my task more and extra easy. Keep rocking. cbd online

    ReplyDelete
  8. I have been checking out a few of your stories and i can state pretty good stuff. I will definitely bookmark your blog cbd cheap

    ReplyDelete
  9. Ensure you get your store out there. Find significant blog entries or become a confided in individual from a discussion applicable to your items. On the off chance that individuals don't have the foggiest idea about your store exists they can't accepting from it.besimple.com/

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Merely a smiling visitant here to share the love (:, btw outstanding style. Fait au Quebec

    ReplyDelete
  13. Grab the extraordinary Oracle Course with PLSQL from Infycle Technologies, the best software training institute in Chennai. Infycle offers the Best Oracle PLSQL Training in Chennai, with various IT demanding courses such as Big Data, Python, DevOps, Selenium, Full-Stack development, etc., in complete hands-on practical training with professional tutors in the field. In addition to that, the mock interviews will be done for the candidates so that they can face the interviews with total confidence. To have all these within your hands, call 7502633633 for a free demoBest Oracle PLSQL Training in Chennai | Infycle Technologies

    ReplyDelete
  14. Infycle Technologies, the best software training institute in Chennai. offers the leading Python course in Chennai for tech professionals, freshers, and students at the best offers. In addition to the Python course, other in-demand courses such as Data Science, Cyber Security, Selenium, Oracle, Java, Power BI, Digital Marketing also will be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7504633633 to get more info and a free demo.

    ReplyDelete
  15. The Blog Your Shared is Very Helpful, This is So good hope we get More blogs on your site like this, This blog is so infomative and exited for your next blog

    Escorts Service in Mahipalpur.

    ReplyDelete
  16. Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post! cbd gummies no corn syrup how to make

    ReplyDelete
  17. Attractive, post. I just stumbled upon your weblog and wanted to say that I have liked browsing your blog posts. After all, I will surely subscribe to your feed, and I hope you will write again soon! name your business

    ReplyDelete
  18. A great content material as well as great layout. Your website deserves all of the positive feedback it’s been getting. I will be back soon for further quality contents. creative business names

    ReplyDelete
  19. mmm.. good to be here in your article or post, whatever, I think I should also work hard for my own website like I see some good and updated working in your site.
    Hasnain

    ReplyDelete
  20. Finish the Selenium Training in Chennai from Infycle Technologies, the best software training institute in Chennai which is providing professional software courses such as Data Science, Artificial Intelligence, Java, Hadoop, Big Data, Android, and iOS Development, Oracle, etc with 100% hands-on practical training. Dial 7504633633 to get more info and a free demo and to grab the certification for having a peak rise in your career.

    ReplyDelete
  21. I can't believe it. I love this article. Thank you for sharing this information. I have been looking for this information for a very long time.

    best astrologer in india!

    ReplyDelete
  22. Thanks for sharing this blog. Very useful Post.

    alcohol prep wipes

    ReplyDelete

  23. Very Informative and useful... Keep it up the great work. I really appreciate your post.
    It shows like you spend more effort and time to write this blog

    https://bangaloredigitalmarketing.com/
    https://bangaloredigitalmarketing.com/digital-marketing-courses-in-bangalore/
    https://bangaloredigitalmarketing.com/seo-company-in-bangalore/
    https://bangaloredigitalmarketing.com/social-media-marketing-agency-in-bangalore/

    ReplyDelete
  24. mahilaon mein kam sex josh matlab sex haarmon ke nimn star yaanee estrojan, chinta aur aadhunik jeevan shailee ke kaaran hone vaale tanaav ke kaaran ho sakatee hai
    ladkiyo ki josh badhane ke liye dawa ka naam
    is samasya se nipatane ke lie ladakiyon ko josh badhaane kee dava viginee plas 100% ka nirmaan kiya gaya. isamen paryaapt maatra mein jadee-bootiyon ka sahee mishran hota hai jo enteeoksident aur phaitoestrojen se bharapoor hota hai, jo mahila sex haarmon ko badhaane mein madad karata hai

    ReplyDelete
  25. Best web design Dubai & Development Services in UAE. Some thinking and planning on your part will help us to design a site that meets your needs.

    ReplyDelete
  26. You made a valiant attempt to fix it up. Following these steps will take care of the problem. Nicely done. Basic wordpress website

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. A managed database service can assist you in setting up, maintaining, managing, and administering your SQL Server databases on Google Cloud. Cisco Distributor KSA

    ReplyDelete
  29. This comment has been removed by the author.

    ReplyDelete
  30. Since 2004 we've been building & releasing digital products. Boost your business with Custom Software Development Dubai agency. Hire dream tech team. Find experienced team of developers for your new business idea.

    ReplyDelete