1

Here is my SQL Server Query that needs to be converted to MS Access -

declare @StartDateTime datetime, @EndDateTime datetime
set @StartDateTime  = '8/17/2013 19:00:00'
set @EndDateTime = '8/18/2013 23:00:00'

WHILE @StartDateTime <> @EndDateTime
Begin
  SELECT TOP 1 tablename.Field2, tablename.Field3
  FROM tablename
  WHERE tablename.SampleDate >= DateAdd(mi,0,@StartDateTime) And tablename.SampleDate <= DateAdd(mi,9,@StartDateTime)    
  SET @StartDateTime = DateAdd(mi,10,@StartDateTime)
  if @StartDateTime = @EndDateTime
   Break;       
END

I appreciate any help. Thanks

HappyLee
  • 435
  • 4
  • 11

1 Answers1

2

That T-SQL script has no direct equivalent in Access. It returns multiple result sets, one for each 10-minute interval between @StartDateTime and @EndDateTime, each containing a single (apparently random) sample from that interval. Access queries only produce one result set (recordset).

If you update your question to explain what you actually want to do with those multiple result sets then we might be able to help you more, but for now the answer to

How can I convert this SQL Server query to an Access query?

is:

You can't.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
  • Makes sense, totally. What if i use a temp table and add resultant rows to that table, and select from temp table at the end? this would produce just one resultant set ! – HappyLee Nov 13 '13 at 17:07