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

Posted on 2007-07-21
Last Modified: 2010-03-20

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 !!

Question by:kishore_peddi
    1 Comment
    LVL 142

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now