SQL Server Integration Services (SSIS)- Percentage Sampling Transformation (Selected and Un-Selected Output) in SSIS


Introduction:

In this article we are going to see how to use a Percentage Sampling Transformation (Selected and Un-Selected Output) both at the same time in SSIS Packaging. A Percentage Sampling Transformation is used to split the dataset into separate outputs based on the percent and send it to different transformations for processing the dataset. This task is specifically used for data mining; we can divide the data and send it across as per our requirement. Let's jump start to see this sample of how to set the properties of the control.

To follow my series of articles on SSIS, go through my profile.

Steps:

Follow steps 1 to 3 in my first article to open the BIDS project and select the right project to work on an integration services project. Once the project is created, we will see how to use the Percentage Sampling to see the flow. Now once the projects is opened drag and drop a source and a Percentage Sampling task as shown in the screen below:

SSISCheUnch1.gif

We can see some red marks on each task which indicates that the tasks are not configured. We need to configure each task so that durimng execution we have a smooth process.

Now let's configure each and every task to execute the package. First let us start with the OLEDB Source as shown in the screen below:

SSISCheUnch2.gif

Now go to the mappings tab and see the list of columns in the source table which are mapped correctly as shown in the screen below:

SSISCheUnch3.gif

Now that we are done with the source, we need to configure the Percentage Sampling task. To do that double-click on the task; that will open the window as shown in the screen below:

SSISCheUnch4.gif

Here we need to specify the percentage of rows to be affected in this transformation and to proceed further. In our sample we are going to select as 40 shown in the screen below:

SSISCheUnch5.gif

Now that we are done with the Percentage Sampling task, we need to configure the destination section where the results are expected. To do that drag and drop the green arrow to the destination task which we created earlier. It will open a configuration window to select the output name from the percentage sampling task as shown in the screen below. Since we have 2 destinations in our package now we will send across the Selected Output and the unselected output based on our requirement as shown in the screen below:

SSISCheUnch6.gif

Now we need to select, out of the 2 properties, which one exactly we require based on our requirement. Here we are going to select as shown in the screen below:

SSISCheUnch7.gif

SSISCheUnch8.gif

Now our screen will have both the selected and the unselected output as shown in the screen below:

SSISCheUnch9.gif

Now we need to configure the destination Excel as shown in the screens below which are self-explanatory.

SSISCheUnch10.gif

SSISCheUnch11.gif

Since we have one more destination, which is the Flat File destination, we need to configure that as well, as shown in the screens below:

SSISCheUnch12.gif

SSISCheUnch13.gif

Now we are ready with our package. We need to build and execute it to see the desired result. So our screen will look like below.

SSISCheUnch14.gif

Now to build and execute press F5 and we can see the result window as shown in the screen below with the amount of rows affected for each destination.

SSISCheUnch15.gif

We can see the number of rows affected and used across. To see the result in Excel, navigate to the path where we configured our destination and open Excel and the notepad; we will see the result as shown in the screen below:

SSISCheUnch16.gif

SSISCheUnch17.gif

Conclusion:

So in this article we have seen how to use the Percentage Sampling to execute dataset and split based on the percent and use it across the requirement.


Similar Articles