Select First Row From an ADO.NET Datasource
Hi, I have an ADO.NET datasource and I need to select the first row in the dataset. How can I do the same? Using Row Sampling or is there any other method to do the same? The problem I am facing with Row Sampling is,I dont want to partition it to selected and unselected rows.I just want a data from the 1st row and the rest of the processing should continue with same dataset,and I dont want to use a Multicast just to do this operation
March 30th, 2011 11:23pm

SELECT TOP 1 Col1, Col2, ... FROM .... WHERE ... Please mark as answer if this helps. Thank you. http://thebipalace.wordpress.com
Free Windows Admin Tool Kit Click here and download it now
March 30th, 2011 11:47pm

you can simply use Select Top 1 * from .... structure to fetch first row in ado.net source query.http://www.rad.pasfu.com
March 30th, 2011 11:47pm

Hi All, I want to do it from the dataset I am fetching. The logic is like: Select * From table1 order by Id desc and I need to get the 1st row,so that I will get the max Id. I dont want to run a separate query ,and I dont want to use an aggregate function. Which is a suitable method?Finding max through looping rows in script component ,or by some other method like Row Sampling? I dont think Row Sampling is the correct approach.
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 12:00am

my question is: why you load all data rows in the source first if you need only first row?!!!! you can use simply select top 1 and this will have better performance than loading all data rows in memory when you don't need them.http://www.rad.pasfu.com
March 31st, 2011 12:02am

No I need the entire dataset and the maxId for the continued processing.
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 12:26am

Try post some samples. What you need should be addressable by using TOP keyword in the T-SQL query, unless you need something that have not described clearly.Please mark as answer if this helps. Thank you. http://thebipalace.wordpress.com
March 31st, 2011 12:28am

If you don't want to use select top 1 ... but you want to load all data in source and then get first row, you can use script component as Jamie posted here: http://consultingblogs.emc.com/jamiethomson/archive/2005/07/27/SSIS-Nugget_3A00_-Select-Top-N-in-a-data_2D00_flow.aspxhttp://www.rad.pasfu.com
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 12:42am

Excellent.This was what I was looking for.Great thanks Reza.
March 31st, 2011 12:58am

And is my assumption correct ? All the data in the script will be processed only after all the data is buffered?
Free Windows Admin Tool Kit Click here and download it now
March 31st, 2011 1:27am

And is my assumption correct ? All the data in the script will be processed only after all the data is buffered? Yes, This is asynchronous script component which loads data first and act on them next.http://www.rad.pasfu.com
March 31st, 2011 1:35am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics