Working with Execute SQL Task in SSIS

Error:

The error occurred after running SSIS package which has two Execute SQL Task component out of that one is outside the “Foreach” loop container is performing the “Select” Query which the second is inside the “Foreach” loop container is performing “Insert”Query as shown in the image down below.

1

In order to diagnose the error student of MSBI training clicked on the Progress tab to see the error in more detail as shown in the image down below.

2

Here the error says that the Variable EmployeeData does not contain a valid data. It means that the “Foreach” loop container is executing first and then the Individual Execute SQL Task component is executing which is outside the “Foreach” container.

Now to understand the error more properly we will see what kind of operation we are executing. Here we want the Execute SQL Task to perform Select Query on a table and select the data and then Insert that data in another table using the Insert Query. Now here what is happening is that first the Foreach container is executing which is containing Insert Query and then the Execute SQL Task component is executing which is containing Select Query.

So no Select and directly executing the Insert is what giving us an error in first place.

Solution:

Even after reading the error when student was not able figure out faculty of
MSBI training provided solution to this error which was very simple. There was just a need to put a connection between the Execute SQL Task component and the “Foreach Loop” Container. For that drag output of Execute SQL Task component and drop on Foreach Loop Container as shown in the image shown below.

4

By doing this connection the components will execute sequentially.

Comments

comments

This entry was posted in MSBI Training in Mumbai and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.