问题
I have a flatfile connection and I'm only interested in the first 10 rows of data. How can I just import the first 10 rows? Row sampling is random so I can't use that. Is there some way I can have some sort of derived column which is an automatic row number or something and then data-split to only keep rows with that id <= 10?
Any help much appreciated!
回答1:
I've used this component --> http://www.sqlis.com/post/Row-Number-Transformation.aspx
The component creates a new variable with a row number. You can use a conditional split to take the first 10 records based on the variable the component creates.
One catch is that you will need to read in the entire file. Depending on your file size you may want to seek another solution.
回答2:
There isn't a direct way of doing that. You can try a work around method by using the "Data rows to skip" property:
You can "invert" your file and skip all first rows -10
回答3:
Just use a lineCount component with a user variable and a conditional Split based on the value of that variable/
来源:https://stackoverflow.com/questions/1476536/how-do-i-retrieve-only-the-top-x-rows-from-a-flatfile-in-ssis