Multiple choice technology programming languages

You have created a cursor named test_cursor inside your stored procedure. Following is the cursor code: --------------------------------------------------------------------- DECLARE @Name AS VARCHAR(100) DECLARE test_cursor CURSOR FOR SELECT empname FROM Employee Order BY empid OPEN test_cursor FETCH NEXT FROM test_cursor INTO @Name WHILE @@FETCH_STATUS <> 0 BEGIN -- Do your internal procesing here FETCH NEXT FROM test_cursor INTO @Name END CLOSE test_cursor DEALLOCATE test_cursor --------------------------------------------------------------------- What correction is required in the code above?

  1. First Deallocate and then close

  2. Use @@FETCH_STATUS = 0 instead of @@FETCH_STATUS <> 0

  3. No need to use "FETCH NEXT FROM test_cursor INTO @Name" again before END statement

  4. Both i and ii

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The stored answer is incorrect. The loop condition @@FETCH_STATUS &lt;&gt; 0 is wrong because a status of 0 indicates success. To process rows, the loop should run while @@FETCH_STATUS = 0. Thus, option 540472 is correct.