On Tue, 18 Oct 2011 10:23:33 -0700 (PDT), iccsi <
inu...@gmail.com>
wrote:
Hi iccsi,
You left off the last number of the SQL Server version, but that does
not matter in this case, as my answer applies to all versions:
1. Try to avoid cursors. The SQL Server implementation of cursors is
slow, and in 99% of cases, you'll get a tremendous gain by replacing a
cursor with set-based logic. If you need help with that, post the
layout of your tables (as CREATE TABLE statements), some sample data
(as INSERT statements), a description of the problem and your existing
code (if you have any). Any of the experts who hang around here will
gladly help you find a better alternative.
2. Definitely try to avoid nested cursors. Start with my arguments
after point 1. Raise that to the power of itself. That's nested
cursors for you.
3. To answer your first question, @@FETCH_STATUS always returns the
status after the last executed FETCH statement. If you use multiple
cursors, it's up to you to track which cursor that was on.
4. And to answer your question on maximum cursor nesting: I don;t want
to know, and neither do you. See above for the reason.
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog:
http://sqlblog.com/blogs/hugo_kornelis