Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2002
  • Last Modified:

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?

Thanks!

0
srafi78
Asked:
srafi78
2 Solutions
 
NightmanCTOCommented:
A subquery - set based operations are almost always faster that multiple updates (and for really large sets, do it in batches).
0
 
BirdbusterCommented:
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 ...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now