Hi there. I have the following code in my stored procedure (I&#039;m only showing the relevant portion, I&#039;ve declared all of the variables):<BR><BR>SELECT @hseoid= MAX(hseo.hseo_id), @hsnm=hs.hs_nm FROM HSOP,HSEO,HS <BR>WHERE HSOP.p_id = @pid AND <BR>HSOP.hso_id = HS.hso_id AND HSOE.hso_id = HS.hso_id <BR>GROUP BY hs.hs_nm<BR><BR>BEGIN<BR>select *, reading_dt = ( select hseo_dt from HSEO where HSEO.hseo_id = HSOEO.hseo_id )<BR>FROM HSOP,HSEO,HS<BR>WHERE HSOP.p_id = @pid AND<BR> HSOP.hso_id = HS.hso_id AND<BR> HSOE.hso_id = HSO.hso_id <BR> AND hseo.hseo_id=@hseoid<BR> AND hs.hs_nm=@hsnm<BR>ORDER BY reading_dt DESC<BR>END<BR><BR>This should return 3 records, however it&#039;s only returning the last record in the result set - the record with the max hseo_id. How do I loop through the records to return all 3 rows? The first select statement returns 3 (I&#039;ve tried it in Query Analyzer), I just don&#039;t know how to write the loop to apply these 3 records to the second SELECT statement. I&#039;ve tried "WHILE @hsnm IS NOT NULL BEGIN [select statement] END", but that only returns the last record multiple times. I would greatly appreciate any help with this, it&#039;s driving me crazy!!<BR><BR>I should note that I&#039;m trying to modify an existing query, I realize you shouldn&#039;t "select *" and all that good stuff, but I&#039;d rather not change it just yet (I&#039;m kind of crunched for time for making this one part work).<BR><BR>Thanks in advance.