Error message while using Select Into
<p>I used below code,</p>

<pre><code>SELECT RowsCount = ROW_NUMBER() OVER(ORDER BY PrijsBoek.[Item Code] DESC, PrijsBoek.[Buy-From BP Code] DESC),
*
INTO #Student
FROM [iqbs DataWarehouse].[Purchase].[factPurchasePriceBooks] as PrijsBoek

DECLARE @MaxRowsCount INT
SET @MaxRowsCount = (SELECT MAX(RowsCount) FROM #Student)
DECLARE @Iter INT
SET @Iter = (SELECT MIN(RowsCount) FROM #Student)
WHILE @Iter &lt;= @MaxRowsCount
BEGIN
    SELECT *
    FROM #Student
    WHERE RowsCount = @Iter
    SET @Iter = @Iter + 1
END
DROP TABLE #Student
</code></pre>

<p>But I get the following error message(s):</p>

<pre><code>Msg 207, Level 16, State 1, Line 7
Invalid column name 'RowsCount'.
Msg 207, Level 16, State 1, Line 9
Invalid column name 'RowsCount'.
Msg 207, Level 16, State 1, Line 14
Invalid column name 'RowsCount'.
</code></pre>

<p>Anybody any clue?</p>