Disadvantages/limitation of the cursor

Explain the disadvantages/limitation of the cursor.

Cursor requires a network roundtrip each time it fetches a record, thus consume network resources.
While data processing, it issues locks on part of the table, or on the whole table.

What are the disadvantages of cursors?

Disadvantages of cursors
- Uses more resources because Each time you fetch a row from the cursor, it results in a network roundtrip
- There are restrictions on the SELECT statements that can be used.
- Because of the round trips, performance and speed is slow

How can you avoid cursors?

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
Define scrollable cursor
You can use keyword SCROLL to make cursor Scrollable.......
Temporary table VS Table variable
Table variable that can be used in stored procedures, functions and batches.......
What is Replication?
Replication is the process of distributing data from one database to another on the same server or servers connected through LAN or the internet.......
Post your comment