What are cursors and when they are useful?



What are cursors and when they are useful?..

Answer / Pawan Kumar Shukla

A cursor in SQL Server is a server-side temporary stored reference to a rowset. It allows executing a sequence of RBAR (Row by Agonizing Row) operations on the rows within a result set. Cursors can be useful for handling complex data manipulation tasks or situations where looping over each row of a result set is necessary.nnExample: Declaring and opening a cursor:nDECLARE MyCursor CURSOR FOR SELECT * FROM Customers;nOPEN MyCursor

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What happens if time-only values are provided as date and time literals?

1 Answers  


List out the different types of locks available in sql server?

0 Answers  


Can a stored procedure call itself or recursive stored procedure? How many levels sp nesting is possible?

1 Answers  


How to set a database state to offline in ms sql server?

1 Answers  


What is use of except clause?

1 Answers  


What are the different SQL Server Versions you have worked on?

0 Answers  


Suppose i have one sql query that contains 2 minute to execute.After one weekly i am executing same query that is taking 5 minute.Why our same query is taking more time.what would be my approach to reduce execution time.Please help.

1 Answers   Cognizant, HCL, Value Labs,


What is the purpose of indexing?

1 Answers  


Why functions are used in sql server?

1 Answers  


What is the importance of a recovery model?

1 Answers  


Tell me about normalization in DBMS.

1 Answers   Honeywell, Zomato,


if 3 duplicate records in a table,i want to delete 2 duplicate records by keeping 1 duplicate and 1 original as it is,how?

5 Answers  


Categories