What is the difference between IN and EXISTS in SQL Server?

Dung Do Tien Oct 19 2020 30

What is the difference between IN and EXISTS clause in SQL Server?

Which case we should use them?

And what is the performance of them?

Have 1 answer(s) found.
  • Below is some difference between IN and EXISTS in SQL Server:

    1. IN

    - Works on the list data set.

    - It's doesn’t work on subqueries resulting in virtual tables with multiple columns.

    - Compares every value in the result list.

    - Performance is comparatively SLOW for larger resultset of a subquery.

     

    2. EXISTS

    - Works only on Virtual tables.

    - It is used with co-related queries.

    - Exits comparison when the match is found.

    - Performance is comparatively FAST for larger resultset of the subquery.

    Marry Christ Oct 19 2020
Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips