SQL Server Cursors Question:

Download Job Interview Questions and Answers PDF

How to avoid cursors?

MS SQL Server Cursors Interview Question
MS SQL Server Cursors Interview Question

Answer:

The main purpose that cursors fulfill is traversing of the row set. Cursors can be best avoided by:

a. Using the SQL while loop: Using a while loop we can insert the result set into the temporary table.

b. User defined functions : Cursors are sometimes used to perform some calculation on the resultant row set. This cam also be achieved by creating a user defined function to suit the needs

Download MS SQL Server Cursors Interview Questions And Answers PDF

Previous QuestionNext Question
Explain the disadvantages of cursors?Explain the cursor lock types?