SQL Server Questions and Answers – Cursor

This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Cursor”.

1. Life cycle of typical cursor involves ______ steps in SQL Server.
a) 2
b) 3
c) 4
d) 5
View Answer

Answer: d
Explanation: The five steps are Declare Cursor,Open,fetch,CLose and Deallocate.

2. Point out the correct statement.
a) A Cursor is opened and populated by executing the SQL statement defined by the cursor
b) After data manipulation, we should close the cursor explicitly
c) A cursor is declared by defining the SQL statement that returns a result set
d) All of the mentioned
View Answer

Answer: d
Explanation: We use cursor when we need to update records in a database table in singleton fashion means row by row.

3. How many type of cursor is present in SQL Server?
a) 3
b) 4
c) 5
d) 6
View Answer

Answer: b
Explanation: SQL Server supports four types of cursor.
advertisement
advertisement

4. Various alternatives to cursor in SQL Server are ___________
a) FOR
b) IF..ELSE
c) WHILE
d) All of the mentioned
View Answer

Answer: c
Explanation: Cursor alternatives are WHILE loop, subqueries, Temporary tables and Table variables.

5. Point out the wrong statement.
a) We should use cursor in all cases
b) A static cursor can move forward and backward direction
c) A forward only cursor is the fastest cursor
d) All of the mentioned
View Answer

Answer: a
Explanation: We should use cursor in that case when there is no option except cursor.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. A dynamic cursor in SQL Server allows you to see __________ data.
a) Updated
b) Inserted
c) Deleted
d) All of the mentioned
View Answer

Answer: d
Explanation: A dynamic cursor allows you to see the data updation, deletion and insertion in the data source while the cursor is open.

7. Which of the cursors further have their subtypes?
a) Static Cursors
b) Dynamic Cursors
c) Keyset Driven Cursors
d) None of the mentioned
View Answer

Answer: d
Explanation: There are three more types of Forward Only Cursors in SQL Server.
advertisement

8. Which of the following FORWARD ONLY Cursor is populated at the time of creation?
a) KEYSET
b) FORWARD_ONLY STATIC
c) FAST_FORWARD
d) All of the mentioned
View Answer

Answer: b
Explanation: A FORWARD_ONLY STATIC Cursor is populated at the time of creation and cached the data to the cursor lifetime. It is not sensitive to any changes to the data source.

9. ____________ cursor is sensitive to any changes to the data source.
a) Static Cursors
b) Dynamic Cursors
c) Keyset Driven Cursors
d) None of the mentioned
View Answer

Answer: c
Explanation: A keyset driven cursor is sensitive to any changes to the data source and supports update, delete operations.
advertisement

10. SQL Server static cursors are always ___________
a) Read-only
b) Write-only
c) Read, Write
d) None of the mentioned
View Answer

Answer: a
Explanation: A static cursor populates the result set at the time of cursor creation and query result is cached for the lifetime of the cursor.

Sanfoundry Global Education & Learning Series – SQL Server.

To practice all areas of SQL Server, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.