What is the difference between IN and EXISTS in SQL Server?
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?
-
M0
Marry Christ Oct 19 2020
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.
* Type maximum 2000 characters.
* All comments have to wait approved before display.
* Please polite comment and respect questions and answers of others.