ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

22 Foreach Loop Container in SSIS Example

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ส.ค. 2024
  • Foreach Loop Container in SSIS Example | Foreach loop container in SSIS | Foreach loop in SSIS
    Download the file\script used in the Video from below link
    drive.google.com/drive/folder...
    SSIS Tutorials: • SSIS Tutorials
    SSIS real time scenarios examples: • SSIS real time scenari...
    SSIS Interview questions and answers: • SSIS Interview questio...
    "insert into FileInfo values ('"+ @[User::FilePath] +"',"+ (DT_WSTR,12) @[User::Cnt] +",GETDATE()) "
    Foreach Loop Container in SSIS Example
    What is the use of foreach loop container in SSIS?
    How do I create a foreach loop container in SSIS?
    What is the difference between for loop container and foreach loop container in SSIS?
    How many loop containers are in SSIS?
    If you have any questions or suggestions please comment on the video or write to me at “aqil33@gmail.com”

ความคิดเห็น • 100

  • @xoxoxo2024xo
    @xoxoxo2024xo 3 ปีที่แล้ว +1

    Hi buddy, thank you for sharing your experience. Even though i had difficulties to understand sometimes, i got the idea and managed to practise it by myself at the end of the day.

    • @learnssis
      @learnssis  3 ปีที่แล้ว +2

      That sounds good. Self practice makes you perfect. Good you learnt it.

  • @EricD_192
    @EricD_192 3 ปีที่แล้ว

    Great channel. Thank you!

    • @learnssis
      @learnssis  3 ปีที่แล้ว +1

      Thank you Erick. Nice to hear that you liked the videos.

  • @sowmyareddy7503
    @sowmyareddy7503 6 หลายเดือนก่อน

    It's really nice explaining for beginners...Thank You

    • @learnssis
      @learnssis  6 หลายเดือนก่อน

      Thank you Sowmya.

  • @viswanathponne
    @viswanathponne 6 ปีที่แล้ว +1

    really i like your ssis all videos

    • @learnssis
      @learnssis  6 ปีที่แล้ว

      Thank you so much. Good to know that.

  • @mallikarjunt29
    @mallikarjunt29 หลายเดือนก่อน

    Thanks man😊 it saved me.

    • @learnssis
      @learnssis  หลายเดือนก่อน

      Glad it worked for you.

  • @ejbernalr
    @ejbernalr 5 ปีที่แล้ว

    Thanks, it's a good video.

    • @learnssis
      @learnssis  5 ปีที่แล้ว

      Nice to hear from you.

  • @kiranraju3225
    @kiranraju3225 3 ปีที่แล้ว

    Hi,
    Really nice video. Thanks for the video.

    • @learnssis
      @learnssis  3 ปีที่แล้ว

      Glad to know that you liked the video. Thank you.

  • @abdulsami6985
    @abdulsami6985 3 ปีที่แล้ว +1

    Dear Aqil , this is really useful, by any chance can we download the video as well please?

    • @learnssis
      @learnssis  3 ปีที่แล้ว

      Thank you. Sure, you can download the video.

  • @rahulgautam511
    @rahulgautam511 3 ปีที่แล้ว

    Hello Aqil,
    As we know, we have three options in the retrieve file names. Could you please tell me how to know where we should the specific option. Generally, I used the fully qualified option. But bit confuse about rest options.
    1. Name and extension.
    2. Fully qualified.
    3. Name only.
    Thanks.

    • @learnssis
      @learnssis  3 ปีที่แล้ว

      Hi Rahul, yes we normally use Fully qualified to get the full path of the file.
      1. however suppose you just want to move the files from one folder to another using foreach loop container then you can use Name and extension and it will just let you have only file name without file path and then based on this value you can set the value of destination file path and can move the file using File System Task.
      3. Suppose you just want to grab the name of the file without extension and want to insert all file names into a sql server table then you can use Name only option.

    • @rahulgautam511
      @rahulgautam511 3 ปีที่แล้ว

      Thanks @@learnssis

  • @sangeethak725
    @sangeethak725 2 ปีที่แล้ว

    How to use sort inside forech container?

  • @amanahmed6057
    @amanahmed6057 ปีที่แล้ว

    8:46
    There is no Folder tab in for each loop container in 2019

  • @MVinodKumar-tt1tu
    @MVinodKumar-tt1tu 9 หลายเดือนก่อน +1

    Hello Sir,
    We created variable Filepath and mapped it with foreach Loop and in Flat File Source we took initial file and in Flat file connection manager properties expression just mentioned Filepath variable. How it worked here sir? like how it looped through all files?Please clarify sir. confused

    • @learnssis
      @learnssis  9 หลายเดือนก่อน +1

      When you mapped the FilePath inside foreach loop container, it means when loop will run the Filepath variable will hold the current filepath that foreach loop container is iterating through.
      Now whatever task you will put inside foreach loop container that will be executed as well for each file\iteration.
      If you will assign the connectionstring string of flat file connection manager with FilePath, then the flat file connection manager can point to that file and that file's data can be read.

    • @MVinodKumar-tt1tu
      @MVinodKumar-tt1tu 9 หลายเดือนก่อน

      @@learnssis Yes got it sir. So as we know enumerator which go through each file in the folder and to process with that file we are using data flow task inside the container. To read the the data of all files we used filepath in the connection string. if we map the filepath to container only it will loop through all files. otherwise without mapping i tried sir it was iterating the same file all the times.
      Am I correct sir?

    • @learnssis
      @learnssis  9 หลายเดือนก่อน +1

      @@MVinodKumar-tt1tu Correct.

  • @BTECH123
    @BTECH123 2 ปีที่แล้ว

    If i executed more than 1 time rows were doubling. Could you tell me how to use delete statement in execute sql statement for this for each loop

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      If you don't want to double the rows, just before the for each loop container use an execute sql task, just put a truncate table statement.

    • @BTECH123
      @BTECH123 2 ปีที่แล้ว

      @@learnssis delete from Table right sir

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      @@BTECH123 yes.

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      @@BTECH123 truncate table would be faster.

    • @BTECH123
      @BTECH123 2 ปีที่แล้ว

      @@learnssis tq sir

  • @data9051
    @data9051 2 ปีที่แล้ว

    This one is difficult I got through everything and then my Foreach Loop and 'Logs' SQL Script got an error that I couldnt figure out:
    Error: 0xC002F210 at Logs, Execute SQL Task: Executing the query "insert into FileInfo values ('C:\Users..." failed with the following error: "Column name or number of supplied values does not match table definition.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Task failed: Logs
    Any help would be appreciated. Moving on forward from here.

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      Its a SQL server related error, it means the insert query to insert the data to Fileainfo table is missing a column or having an extra column. Just double check the insert query. Open the execute SQL task. Open SQL command, don't go to expression, copy the insert query and try to run the insert query on SQL server management studio on the database where logs table FileInfo exists. You might be missing identity clause to the Id column, its my guess.

  • @MD-lu6lb
    @MD-lu6lb ปีที่แล้ว

    Hello there,
    How to generate a single flat file from multiple values from for each loop like I have 5 groups but in my out put sometimes I need single destination and sometimes multiple output . Like 5 flat files destination and sometimes one destination it depends on the requirements. Please help !

    • @learnssis
      @learnssis  ปีที่แล้ว +1

      You can take a look at this video "for each loop ado enumerator"
      th-cam.com/video/GlznRaeQkx4/w-d-xo.html
      You would need to select the distinct groups in an object variable using execute sql task and then you can use foreach loop container with ado enumerator, the files will be created for each group.

    • @MD-lu6lb
      @MD-lu6lb ปีที่แล้ว

      @@learnssis how do I populate each group in one destination using union all? Thank you!

    • @learnssis
      @learnssis  ปีที่แล้ว

      @@MD-lu6lb If you want to use Union All then you don't need to use the foreach loop here, just use a data flow task, and then in OLE DB Source, write multiple sql queries with union all and in the destination use a flat file destination, this will fetch data from sql server according to the query whether there is a union all or not and will write the data to a flat file.

    • @learnssis
      @learnssis  ปีที่แล้ว +1

      You can take a look at this example as well, where we merged data to a single CSV file.
      th-cam.com/video/4fnTxqWoPIc/w-d-xo.html

    • @MD-lu6lb
      @MD-lu6lb ปีที่แล้ว

      @@learnssis Thank you very much!

  • @ankbala
    @ankbala 3 ปีที่แล้ว

    At 4:34, header column names having double quotes.. how to get rid of them?

    • @learnssis
      @learnssis  3 ปีที่แล้ว +1

      Sorry, I don't see double quotes in the Header at that location. Although if there are double quotes in the header then, while creating the connection, uncheck "column names in the first data row" | set "Text Qualifier" to ". This won't select any double quote from the file, now click on the checkbox "column names in the first data row" again, so that Header information from flat file can be used.

    • @ankbala
      @ankbala 3 ปีที่แล้ว

      @@learnssis yeah..but in the next step how to do mapping with OLE DB Destination? did I miss any step?

    • @learnssis
      @learnssis  3 ปีที่แล้ว +1

      @@ankbala If the column names in source CSV file and SQL table are same then they will be mapped automatically, otherwise on the left side, you will have columns from csv file and on the right side, you will have columns from sql table, so you can map the columns like, firstname from flat can be mapped with firstname of sql table and so on.

    • @ankbala
      @ankbala 3 ปีที่แล้ว

      @@learnssis Thank you.

  • @sriniwaaskorampalli8145
    @sriniwaaskorampalli8145 2 ปีที่แล้ว +1

    Hi Sir,
    Canu please Provide Code for Insert statement in Logs through Expression... I am getting error

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      If you check the description of the video, in each video I have shared a link to download the files, create table statement, and code used in the SSIS package. There is a folder for each video and you can download the respective code from there.

    • @sriniwaaskorampalli8145
      @sriniwaaskorampalli8145 2 ปีที่แล้ว

      @@learnssis My bad sir...i have downloaded all those but dint give a look at the code.txt...thanks sir.

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      @@sriniwaaskorampalli8145 No problem.

  • @sriniwaaskorampalli8145
    @sriniwaaskorampalli8145 2 ปีที่แล้ว

    hi sir, why i am getting all data in double quotes in SQL table

    • @learnssis
      @learnssis  2 ปีที่แล้ว +1

      Right click on the flat file connection manager, select edit | Under Text qualifier put a double quote and save the package. Now rerun the package.

    • @sriniwaaskorampalli8145
      @sriniwaaskorampalli8145 2 ปีที่แล้ว

      @@learnssis thanks a lot sir....got it.....

  • @lakshmiboddu7620
    @lakshmiboddu7620 ปีที่แล้ว

    I want to display same date value into a table whatever the date available in filename .

    • @learnssis
      @learnssis  ปีที่แล้ว

      In this video, I have shown how to get the file name from file path and insert the value into a SQL server table
      th-cam.com/video/6Mz8hNg45ME/w-d-xo.html
      You can use a right function if the date in file is in the end to get the date or you can use substring function as well.

    • @learnssis
      @learnssis  ปีที่แล้ว

      If you can give an example of file name then I will try to make a video on that.

    • @lakshmiboddu7620
      @lakshmiboddu7620 ปีที่แล้ว

      Thank you for your response.I have many filenames like CustomerData_10.10.21_11.56_PM.csv
      From this file name i need date should be displayed as YYYYMMDD format.

    • @learnssis
      @learnssis  ปีที่แล้ว

      @@lakshmiboddu7620 Okay, I will try to make a video on this one.

  • @sagittariusguy2011
    @sagittariusguy2011 6 ปีที่แล้ว +1

    y did u bring the ROWCOUNT in picture , is it really necessary just to confuse people .

    • @learnssis
      @learnssis  6 ปีที่แล้ว +2

      Your point of view is correct as well. I thought to include it so that new people know that when they are loading data from different files at the same time they can capture the record count as well. But your point is valid.

    • @TheSonuaujla
      @TheSonuaujla 6 ปีที่แล้ว +1

      Sometimes it's really helpful to learn an extra step. RowCnt is very helptul

    • @dhavaldalasaniya
      @dhavaldalasaniya 5 ปีที่แล้ว

      It is really helpful to learn full Technics of production.

  • @aerobat150M
    @aerobat150M 5 ปีที่แล้ว +2

    You should take a little more time to explain what you're doing on each step. I had to stop and rewind the video MANY times to figure out what you did. Also, it was extremely difficult to figure out what you typed in the SQL Statement Source in the Logs task.

    • @learnssis
      @learnssis  5 ปีที่แล้ว +1

      Thanks for your comment, I will try to improve the things mentioned in your comment.

  • @AshishPatel-yl1bk
    @AshishPatel-yl1bk ปีที่แล้ว

    How to loop load latest file present in 10 different folder in root directory ?

    • @learnssis
      @learnssis  ปีที่แล้ว

      Is the schema of file is same in all 10 folders ?

    • @AshishPatel-yl1bk
      @AshishPatel-yl1bk ปีที่แล้ว

      @@learnssis Its log file, i want loop through log files from all folder into one single table. Basically I want to read one latest file for each folder and load one by one to destination table.

    • @learnssis
      @learnssis  ปีที่แล้ว

      @@AshishPatel-yl1bk Take a look at this to understand how to process the most recent file from a folder.
      th-cam.com/video/O1xVlKq8cqY/w-d-xo.html

  • @tejaswinerella5223
    @tejaswinerella5223 ปีที่แล้ว

    Hii Aquil, I'm facing this issue Can you please help me with this
    Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "insert into FileInfo values ('C:\Files\CSV Files\C..." failed with the following error: "Incorrect syntax near '.3520'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
    Task failed: Execute SQL Task
    Warning: 0x80019002 at Foreach Loop Container: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
    Any help would be appreciated

    • @learnssis
      @learnssis  ปีที่แล้ว

      Can you paste the code to insert data into audit_log here, it seems like there is some syntax issue with the code.

    • @tejaswinerella5223
      @tejaswinerella5223 ปีที่แล้ว

      @@learnssislearnssis Thanks for the reply
      I'm passing this code in Execute SQL task can you please validate it once
      sqlStatement: insert into FileInfo values ('C:\Files\CSV Files\Customer1.CSV',0,GETDATE())
      SQLStatementSource : "insert into FileInfo values ('"+ @[User::FilePath] +"',"+ (DT_WSTR,12) @[User::cnt] +",GETDATE()) "

    • @learnssis
      @learnssis  ปีที่แล้ว

      @@tejaswinerella5223The expression seems okay to me. When you directly execute this query on SSMS then does it fails
      insert into FileInfo values ('C:\Files\CSV Files\Customer1.CSV',0,GETDATE())

    • @oussamaelarbi9300
      @oussamaelarbi9300 11 หลายเดือนก่อน

      Create your FileInfo Table with this expression and try again : Create table FileInfo(
      Id int identity ,
      FilePath text,
      RecordCount int,
      Dated datetime
      )
      GO

  • @dilipkumar-ck1nc
    @dilipkumar-ck1nc 2 ปีที่แล้ว

    Can u write the code and update to notepad plz

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      Hi Dilip, I have added the code to notepad and uploaded.

  • @verysecret541
    @verysecret541 3 ปีที่แล้ว +1

    great video, but please stop saying 'You know" I have counted 'You know" 182 times. Its just too often.

    • @learnssis
      @learnssis  3 ปีที่แล้ว

      Yeah, you are right. I will try to stop saying that :)

  • @SurajitMetya
    @SurajitMetya 2 ปีที่แล้ว

    For each loop container is working without """"variable mapping : user filepath😂😂😂😂

    • @learnssis
      @learnssis  2 ปีที่แล้ว +1

      Yeah variable mapping is optional. It will run but you won't know which file it is iterating through.

    • @SurajitMetya
      @SurajitMetya 2 ปีที่แล้ว

      @@learnssis love ur video 😍😍😍😍

    • @learnssis
      @learnssis  2 ปีที่แล้ว +1

      @@SurajitMetya Thanks so much for your kind words.

    • @SurajitMetya
      @SurajitMetya 2 ปีที่แล้ว

      @@learnssis ur linkedin I'd please

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      @@SurajitMetya it is
      www.linkedin.com/in/aqil-ahmed-01628058/

  • @gopalreddyguraka6769
    @gopalreddyguraka6769 ปีที่แล้ว

    Ur content was good but ur too fast explanation it makes to hard and irritating to replay back

    • @learnssis
      @learnssis  ปีที่แล้ว

      Yes Gopal you are right, in majority of videos I am too fast, I am just trying to improve this for future videos. Actually in this fast life every thing is fast 😃

  • @alihaider6435
    @alihaider6435 4 ปีที่แล้ว

    apkay pas knowlg hai ap chaho to or zada achay andaz se smjha saktay ho ap aysay smjha rahay ho jesay k hum phalay se he sab kuch jantay hain bhater he har step ko ache tarhan explian karain or vid bananay se phalay kuch kha pe lia karain awaz me dam paida karain wesay sab kuch acha hai bus explain thora or achay se karo aysa ka jesa kesi ko sikha rahay ho ye na lagay kay phalay se he sekha hoa hai just revise kara rahay ho

    • @learnssis
      @learnssis  4 ปีที่แล้ว +1

      Bahut bahut shukriya aake suggestions ke liye. Will take care of it.

    • @alihaider6435
      @alihaider6435 4 ปีที่แล้ว

      @@learnssis Thanks sir for your reply

  • @DG-wc8iz
    @DG-wc8iz 3 ปีที่แล้ว

    Your explanation is like.. this is Tajmahal okay then this is tower of London.. okay this is Burj Khalifa... This is Nalasopara
    No explanation makes video boring and hard to understand.

    • @learnssis
      @learnssis  3 ปีที่แล้ว +1

      Thanks for your comment, yeah this video is not easy to understand for a new learner. I have added few extra steps like row count transformation and logging to it which makes the video a bit complicated for new learners. This was my very initial video so I understand this is not great. Anyway thanks for sharing your videos. I truly accept it.

  • @Shankar-zi3yk
    @Shankar-zi3yk 10 หลายเดือนก่อน

    this is not good explanation for a beginner level candidate who dont know about enumerators u are not explaining each and evry point u are doing which u know and also u are using the rowcount which uhavent completd of teaching about that which will confuse beginners like me plz explain clearly

    • @learnssis
      @learnssis  10 หลายเดือนก่อน

      I am really sorry Shankar, you are right I should have explained things more clearly and in more details.
      Recently I created one more video on the same topic as well.
      th-cam.com/video/BjpaSxMZMxs/w-d-xo.html
      Actually I covered every enumerator option differently like File, Enumerator, ADO enumerator, Item Enumerator, thus I have video on each enumerator type
      23 Foreach loop ado enumerator in SSIS example
      th-cam.com/video/GlznRaeQkx4/w-d-xo.html
      70 Foreach loop item enumerator in ssis example
      th-cam.com/video/2RMyvJoMefM/w-d-xo.html

    • @Shankar-zi3yk
      @Shankar-zi3yk 10 หลายเดือนก่อน

      @@learnssis I have a doubt too u have change the filepath dynamically right how it's taking

  • @LazarJovovicLaki
    @LazarJovovicLaki 7 ปีที่แล้ว +1

    Your verbal skills aren't good. Going forward, you should be using text comments instead. Technically, tutorial is useful.

    • @learnssis
      @learnssis  7 ปีที่แล้ว +4

      Thanks for your comment. Actually English is not my native language, I will try to improve it. Some people do not like reading text comments as well, will think about it.

    • @TheSonuaujla
      @TheSonuaujla 6 ปีที่แล้ว +3

      I think Verbal skills are good. it just the sound quality of this video.

    • @dhavaldalasaniya
      @dhavaldalasaniya 5 ปีที่แล้ว +1

      Your verbal skills are upto the mark to let me learn. keep doing it ..

  • @sangeethak725
    @sangeethak725 2 ปีที่แล้ว

    How to use sort inside forech container?

    • @learnssis
      @learnssis  2 ปีที่แล้ว

      Hi Sangeetha, in Foreach loop container we don't have the option to load the files in an order, however I used another solution for this problem.
      th-cam.com/video/rtYir_2SlPM/w-d-xo.html