Q&A

Q1:Can I have more than one cursor active in a SQL script at a time? Using the same tables?
A1: There is no limitation on the number of cursors that you can have active and open in a SQL script. In addition, you can access the same table or tables from the different cursors.
Q2:Can cursors fetch more than one row at a time?
A2: The answer is a little more complicated than a yes or no. If you are using server-side cursors, then no, you can only fetch one row at a time. However, if you are using client-side cursors, you could fetch multiple rows at a single time. This is because of the way client-side cursors retrieve the data from the database.
Q3:Can I use cursors inside triggers or stored procedures?
A3: Although you can use cursors inside ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.