title: Result set in column not row
body: <p>I need to get the minimum values for 16 columns at a time. </p>
  
  <p>I.e. 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16</p>
  
  <p>minimum= 1</p>
  
  <p>I need this to slid over 1 ever for a new set of 16 and get the minium values for that one as well </p>
  
  <p>i.e. 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17</p>
  
  <p>Minimum 2</p>
  
  <p>There are 2571 columns with 11,000 rows. </p>
  
  <p>So far I am getting the rows from:</p>
  
  <pre><code>DECLARE @Start INT =1 
  DECLARE @End INT=16 
  Begin Transaction
  SELECT * 
  FROM   (SELECT Row=Row_number() 
                       OVER ( 
                         ORDER BY column_name), 
                 column_name 
          FROM   information_schema.columns 
          WHERE  table_name IN ( '100', '200', '300', '400' ) 
                 AND column_name NOT IN ( 'time', 'scan' ))Row 
  WHERE  row &gt;= @start 
         AND row &lt;= @end 
  Commit
  </code></pre>
  
  <p>This is giving me the first 16 columns but in a column. 
  I would like to open this up and put the returning results into a cursor where i can execute it for row by row analysis.</p>
  
  <p>Something like this, Though if I add 1 to the row number for each one I want it should move it over.</p>
  
  <pre><code>DECLARE @Column01 NVARCHAR(50), 
          @Column02 NVARCHAR(50), 
          @Column03 NVARCHAR(50), 
          @Column04 NVARCHAR(50), 
          @Column05 NVARCHAR(50), 
          @Column06 NVARCHAR(50), 
          @Column07 NVARCHAR(50), 
          @Column08 NVARCHAR(50), 
          @Column09 NVARCHAR(50), 
          @Column10 NVARCHAR(50), 
          @Column11 NVARCHAR(50), 
          @Column12 NVARCHAR(50), 
          @Column13 NVARCHAR(50), 
          @Column14 NVARCHAR(50), 
          @Column15 NVARCHAR(50), 
          @Column16 NVARCHAR(50) 
  
  DECLARE @Start INT =1 
  DECLARE @End INT=16 
  
  
  DECLARE db_cursor CURSOR FOR 
    SELECT column_name 
    FROM   (SELECT Row=Row_number() 
                         OVER ( 
                           ORDER BY column_name), 
                   column_name 
            FROM   information_schema.columns 
            WHERE  table_name IN ( '100', '200', '300', '400' ) 
                   AND column_name NOT IN ( 'time', 'scan' ))Row 
    WHERE  row &gt;= @start
           AND row &lt;= @end 
  
  OPEN db_cursor  
  FETCH NEXT FROM db_cursor INTO  @Column01 ,@Column02
  
  WHILE @@FETCH_STATUS = 0  
  BEGIN  
  
        --do work here    
        print @Column01 + ' ' + @Column02
  
      FETCH NEXT FROM db_cursor INTO  @Column01 , 
  @Column02 
  END  
  
  CLOSE db_cursor  
  DEALLOCATE db_cursor
  </code></pre>
  
  <p>I know I can pivot it but would that work for what i want since i do not need an aggregate? Any suggestions?</p>