您不能将SELECT INTO与表变量一起使用,SELECT INTO也会创建一个表,因此您不能首先创建表
试试这个
DECLARE @rowtemp table(TestRunID int, RunOrder int) INSERT INTO @rowtemp SELECT TestRunID, ROW_NUMBER() OVER (ORDER BY TestRuns.TestTime ASC) AS 'RunOrder' FROM TestRuns WHERE RunID = @runID