为什么 DECLARE 语句使声明的变量成为全局变量?
例如:
SET NOCOUNT ON
GO
DECLARE @LoopCounter TINYINT = 3
WHILE @LoopCounter <> 0
BEGIN
DECLARE @TempDataSource TABLE ([ID] TINYINT)
SELECT [ID]
FROM @TempDataSource
INSERT INTO @TempDataSource ([ID])
VALUES (1)
,(2)
,(3)
SET @LoopCounter = @LoopCounter - 1
END
SET NOCOUNT OFF
GO
给我:
它应该在所有情况下都不返回吗?