SSMS Set Statistics Time On / Off打印多行而不是仅打印一行

问题描述 投票:0回答:1

当我运行查询时,它显示多个执行时间,而不是一个。我只想要一个,所以该怎么做才能只打印一个时间戳?

SET STATISTICS TIME ON
DECLARE @firstNum INT, @secondNum INT, @thirdNum INT, @evenSum INT
SET @firstNum = 1
SET @secondNum = 2
set @thirdNum = 2
SET @evenSum = 2
WHILE (@thirdNum <= 4000000)
BEGIN
    SET @thirdNum = @firstNum + @secondNum
    SET @firstNum = @secondNum
    SET @secondNum = @thirdNum
    IF (@thirdNum % 2) = 0
    SET @evenSum += @thirdNum
END
PRINT 'Answer = ' + CONVERT(VARCHAR, @evenSum)
SET STATISTICS TIME OFF
sql ssms ssms-2012
1个回答
0
投票

如果您从代码中删除PRINT 'Answer = ' + CONVERT(VARCHAR, @evenSum)那么它将不会打印多个执行时间。

© www.soinside.com 2019 - 2024. All rights reserved.