difference in using loop and using cursor in sql

most interviewer ask this question


3 Answers
1-3 of  3
3 Answers
  • Hope this may helps you 
    Loop is used to repeatdely call a block of code in sql
    But cursor is used to iterate through the rows of the specified record set  which means it repeatdely call a block of code + iterate through a row of specific record.
    For Better understanding C# Example
    We use for,while loop in c#  which works same as loop in sql and
    we use foreach which work same as cursor in sql 
     

  • Loop will execute code over and again as  settled number of times 

    CURSOR will get and process/execute the code till end of the cursor information.

  • loop will execute code repeatedly as mintioned fixed number of times
    CURSOR will fetch and process/execute the code till end of the cursor data.

Sql Server

Didn't get the answer.
Contact people of Talent-Sql Server directly by clicking here