SSIS Result set, Foreachloop and Variable

夙愿已清 提交于 2019-12-05 05:16:28

I figured out my own question. I will add it here in case someone else have the same issue.

  1. On the SQL query the first column should be your key result. for example mine was the email.

  2. In the SQL Task under General, set Resultset to "Full Result rest"

  3. In the SQL Task under Result Set, set variable with "0" as result name, create a variable as "Object" data type for the email column and click ok to save and exit. Example: email_Ob

  4. By going to the variable window, create more variable for the other columns as Object and since I'm using this for email task I need to convert from Object to String, so I need to create another variable as string for each one

    Example:

           **Variable Name**       **Datatype**
               email_Ob                Object
               Name_Ob                 Object
               email_St                String
               Name_St                 String
    
  5. Foreach Loop task Under Collection change the following:

    Enumerator: Foreach ADO Enomator

    ADO object Source variable: Select the key variable (email_Ob)

    Select Rows in the first table

  6. Foreach Loop task under Variable Mappings add the variable with String data type the same order as on your SQL query. Click OK to save and exit.

  7. Now you can add the Email Task inside Foreach Loop and use those String variable as part of the email or you can use it for any other task.

Hope this help and if you have any questions feel free to ask. Doing this way, I was able to add more columns as need it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!