只是一个简单的问题,我如何优化我的SQL服务器查询,以及在循环时循环替换的任何方法?...谢谢
DECLARE @TOTAL INT, @COUNT INT=1, @ID INT,@FROMDATE DATE= '2016-11-01', @TODATE= '2016-11-10'
SELECT @TOTAL = COUNT(1)
FROM NUMBERS
WHILE @COUNT <= @TOTAL
BEGIN
SELECT @ID = ID
FROM #TEMP
WHERE ROW_ID = @COUNT
DECLARE @OUTPUT VARCHAR(MAX) = '';
EXEC SPSAMPLEPROC @ID, @FROMDATE, @TODATE, @OUTPUT OUTPUT;
SELECT @COUNT = @COUNT + 1;
END