Loop through table by row T-SQL
<p>In T-SQL I want to loop through a table in a stored procedure, by reading a row by row. </p>

<pre><code>DECLARE @IMAX INT,
        @ICOUNT INT,
        @INTERFACE_ID_36 INT,
        @INTERFACE_ID_38 INT

SELECT * FROM INTERFACE_36_DATA

SET @IMAX = @@ROWCOUNT
SET @ICOUNT = 1

WHILE(@ICOUNT &lt;= @IMAX)
    BEGIN
        SELECT @INTERFACE_ID_36 = Interface_ID
        FROM INTERFACE_36_DATA
        WHERE ROW_NUMBER() OVER (ORDER BY id) AS  = @ICOUNT   --syntax error here

            IF @INTERFACE_ID_36 = 10
                SET @INTERFACE_ID_38 = 0
            ELSE IF @INTERFACE_ID_36 = 
</code></pre>