title: using cursors and displaying row numbers
body: <p>I have declared the following cursor and have used a local variable <code>@RowNo</code> to print the number of each each row.</p>
  
  <pre><code>  declare TheCursor cursor 
    for select productName from products
    declare @RowNo int 
    declare @productName nvarchar(50)
    set @RowNo = 1
    open TheCursor
    fetch next from TheCursor into @productName
    print @RowNo
    print @productName
    set @RowNo = @RowNo+1
    set @productName=''
  
   while @@FETCH_STATUS=0
      begin
       fetch next from TheCursor into @productName
       print @RowNo
       print @productName
       set @RowNo = @RowNo+1
       set @productName=''
      end
   close TheCursor
   deallocate TheCursor
  </code></pre>
  
  <p>I am trying to find any other way to assign / define a number to each row and display it in the console. I have found the function <code>Row_number()</code> and used it like  <code>select ROW_NUMBER() over (order by (select 0)) As Rownumber</code> to do it. </p>
  
  <p>I want to know if it is possible to use the <code>KEYSET</code> in my cursor to do it? How can I do it with <code>KEYSET</code>?</p>