Cursor or subquery?

Which one would be more efficient using a cursor in the stored proc to filter out un-wanted data or to use a dynamic subquery with the IN clause while updating?


Who is Participating?
BirdbusterConnect With a Mentor Commented:
If I was you I would definetly not use a cursor and I would also try to avoid using a subquery, instead i would try to perform an INNER JOIN, but if that won't work for you case then I would use the Subquery.
You should try to avoid using a Cursor in Microsoft SQL Sever, because its very poor performance when compared to a cursor in Oracle.
Microsoft SQL Server works the best with Set Based querys and not cursors.

Hope this helps.

Thanks ...
NightmanConnect With a Mentor CTOCommented:
A subquery - set based operations are almost always faster that multiple updates (and for really large sets, do it in batches).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.