Tuesday, May 17, 2011

SSIS Selective Rows Count

I came across a question today about how to process only the first 10000 rows from a flat file.
It could be done by 3 ways, either using the "RowNumber transformation" from http://sqlis.com/post/Row-Number-Transformation.aspx .

or by using a "Script task" which I'll blog about it later or by using the "Row Sampling" Task.

"Row Sampling" would be the easiest way if you need to grab the FIRST 1000 or the FIRST any number.

But using a "Script Task" or the "RowNumber transformation" will grab any selective rows, such as "Grab rows 150 to 400".

Practice  package can be downloaded from : http://www.box.net/shared/ajzt5nccue

I'm using here the Data Generator source Task which could be downloaded for free from http://sqlis.com/post/Data-Generator-Source-Adapter.aspx
just to generate 5000 rows, you can use a flat file as normal.

 RowNumber Transformation, adds a column named 'RowNumber' or any name you name it here.


 Conditional Split to split the first 1000 rows -- RowNumber <= 1000

 The results.
Hope that helps someone.