use*_*032 0 sql t-sql sql-server
我不知道我的查询有什么问题,但它并没有突破while循环.我认为这是我如何计算时间但不确定.
DECLARE @start DATETIME = GETDATE(), @currenttime INT = 0
while @currenttime <= 1 --- represent min
begin
[execute Query]
' this will always return 0 and keep executing query even though the 1 min has been reached
set @currenttime = CONVERT(INT, DATEDIFF(s, @start, GETDATE())%3600/60)
end
Run Code Online (Sandbox Code Playgroud)
另一种方法是更改while循环的条件:
SELECT @Start = GETDATE()
WHILE DATEDIFF(SECOND, @Start, GETDATE()) < 3 -- Execute the loop for 3 seconds
BEGIN
SELECT 1
END
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
370 次 |
| 最近记录: |