1. Sampling is to
select a random subset of given set of data. Suppose we have 1000 rows in our
table. And we have to select any 10 rows randomly, then we use sampling
transformation.
In
SSIS, we can do sampling in 2 ways i.e. Row Sampling and Percentage Sampling.
In this BOK, we are going to see how to use Row Sampling transformation in SSIS
Packaging. Row sampling is used to randomly select some rows and move it as
output to the required process as and when required to divide the rows. Example
of using this transformation is say example if we want to select some randomly
10 users of a community for a random prize then we can use this transformation.
In this process we are going to see an example on how to use this process for
the selected output values.
Steps:
First select the right project to work on integration
services project. Now once the projects is opened drag and drop a source and a
row sampling task as shown in the screen below
Now we can see the red mark on to the control which
indicates that the controls are yet to be configured. Now configure the source
connection with selecting any table of your choice. Now your output will look like below
Now we need to configure the Row Sampling task, double click
the task will open the screen as below –
Here we can specify the number of random rows can be
selected and the name for the Sample output selected and unselected. Since in
our example we are going to see the Selected Output we will see on how to use
it. Now after specifying the number of rows just clicks on OK button. Now drag
and drop the Flat File Destination as shown in the below screen –
Now drag the green line from the Row Sampling to the Flat
File destination task. It will open a window as shown in the below screen
Here we have selected the Selected output as the Output to
get the data as we can see in the screen above. We can also select only that
columns that we want . We don’t need to fetch all the columns if not required
as below in columns tab of row sampling transformation-
Now click on OK to do the further configuration of the
destination as shown in the below screen –
Once the configuration is done we can see the screen as
below-
Now our package is ready to execute. Press F5 and execute
the project we can see the screen as below which indicates that the package is
executed successfully –
We can see only 10 rows are randomly selected and passed to
the destination. We can see the output by opening the file which we gave in the
destination configuration section. You can see the result as shown in the
screen below –










No comments:
Post a Comment