?
Solved

Why "EXISTS" is more efficient than "IN" in SQL Server 2000 / 2005 !!

Posted on 2007-07-21
1
Medium Priority
?
210 Views
Last Modified: 2010-03-20
Hi,

Can you please explain me why "EXISTS" is more efficient than "IN" in SQL Server 2000 / 2005 ? Please explain me in simple terms with simple examples.

Appreciate your time and patience !!

Thanks
0
Comment
Question by:kishore_peddi
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 19541871
EXISTS can (and will) stop the subselect on the first match, while IN has to get the complete list of the subselect first, and then do the match.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question