Simple example for difference between select and cursor in sql

Answer Posted / manoj pandey

- SELECT is a Query operator, which is also called a set-based approach.

- CURSOR is a looping operator, which is also called a iterative approach or no-set based approach.

Ideally SELECT is more performant than CUSROSR, but there are certain scenarios when CURSOR are the last approach and sometimes beneficial.

More about Cursors:
- Cursor Life Cycle: http://sqlwithmanoj.wordpress.com/2010/10/24/sql-server-cursor-life-cycle/
- Cursor Performance: http://sqlwithmanoj.wordpress.com/2011/02/07/avoid-cursors-or-use-them-optimally/

Check my blog for more Interview Questions: http://sqlwithmanoj.wordpress.com/interview-questions/

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the properties of sub-query?

829


How do I create a stored procedure in sql server?

735


what is a join and explain different types of joins? : Sql server database administration

757


List types of tables in SQL Azure?

122


What is a livelock?

754


what are the disadvantages of cursors? : Sql server database administration

739


How to delete all rows with truncate table statement in ms sql server?

733


What is the most common trace flags used with sql server?

728


Explain tables in SQL Azure?

114


What is a fan-out query in SQL Azure?

117


Explain what is “asynchronous” communication in sql server service broker?

710


Can we store videos inside the sql server table?

751


What is the sql case statement used for? Explain with an example?

785


What is transaction server implicit?

730


What is the purpose of optimization?

762