简体   繁体   English

将SQL Server查询转换为MS Access

[英]Convert SQL Server Query to MS Access

Here is my SQL Server Query that needs to be converted to MS Access - 这是我的SQL Server查询,需要将其转换为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 谢谢

That T-SQL script has no direct equivalent in Access. 该T-SQL脚本在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. 它返回多个结果集,@StartDateTime和@EndDateTime之间的每10分钟间隔一个,每个都包含该间隔中的一个(显然是随机的)样本。 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? 如何将此SQL Server查询转换为Access查询?

is: 是:

You can't. 你不能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM