SQL Server 2014 Cursor in stored procedure never seems to move past the first record. I.e it does not loop

Examine the following piece of code:
        set @RM = 'some value'
        set @BASEQTY = 1
        DECLARE UOMSCHED CURSOR SCROLL FOR
      SELECT UOFM,EQUOMQTY FROM tablename WHERE column = @RM
      OPEN UOMSCHED
      FETCH first FROM UOMSCHED INTO @UOFM,@EQUOMQTY
        WHILE  @@FETCH_STATUS = 0
        BEGIN
                  set @cursor_Rows = @@Cursor_rows
                  SET @RMQTYCONVERTED = @BASEQTY /@EQUOMQTY
                  INSERT INTO RM_QTYS (RM_ID,[rmUOM],[QTYrequired])
                  VALUES (@RM,@UOFM,@RMQTYCONVERTED)
            END
      FETCH next FROM UOMSCHED INTO @UOFM,@EQUOMQTY
      CLOSE UOMSCHED;
      DEALLOCATE UOMSCHED;

In this example the SQL Query returns 5 rows. The @@cursor_rows variable also shows that the cursor has 5 rows.
However the variables @UOFM and @RMQTYCONVERTED always store the values of the first record. In other words the cursor does not seem to move to the next record. The purpose of this loop is to determine the quantity of something in 5 different units of measure. The units of measure and the conversion factors are stored in 'tablename'. All 5 calculated results are then inserted into another table 'RM_QTYS'. If there is a way to perform this without a cursor I am happy as well.
AdimitroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chaauCommented:
The FETCH NEXT command should be inside the WHILE scope, i.e before the END:
 WHILE  @@FETCH_STATUS = 0
        BEGIN
                  set @cursor_Rows = @@Cursor_rows
                  SET @RMQTYCONVERTED = @BASEQTY /@EQUOMQTY
                  INSERT INTO RM_QTYS (RM_ID,[rmUOM],[QTYrequired])
                  VALUES (@RM,@UOFM,@RMQTYCONVERTED)
                 FETCH next FROM UOMSCHED INTO @UOFM,@EQUOMQTY
       END

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jose TorresCertified Database AdministratorCommented:
chaau's answer is correct
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.