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

Answers were Sorted based on User's Feedback



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

Answer / monal

HERE'S THE SIMPLE ANSWER:
WHEN YOU USE 'IN', WHILE CHECKING FOR WHERE CONDITION SQL
SERVER ENGINE DOES WHOLE TABLE SCAN.
IF YOU USE 'EXISTS' AS SOON AS ENGINE FINDS THE REQUIRED
ROW IT WILL STOP EXECUTING QUERY AND GOING FURTHER SCANNING
TABLE.

SO BASICALLY EXISTS IS FASTER AS COMPARED TO IN.

Is This Answer Correct ?    146 Yes 14 No

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

Answer / vijaykumar dolli

using the IN clause, you're telling the rule-based
optimizer that you want the inner query to drive the outer
query (think: IN = inside to outside).

When you write EXISTS in a where clause, you're telling the
optimizer that you want the outer query to be run first,
using each value to fetch a value from the inner query
(think: EXISTS = outside to inside).

Thank you

Is This Answer Correct ?    106 Yes 15 No

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

Answer / pranab

IN:

Returns true if a specified value matches any value in a
sub-query or a list.

Exists:

Returns true if a sub-query contains any rows.

Is This Answer Correct ?    27 Yes 8 No

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

Answer / navneet sharma

IN work like a OR in sql query but in is faster than OR in
case of IN server will search whole table
EXISTS is use to find the required row and does not search
whole table

Is This Answer Correct ?    29 Yes 16 No

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

Answer / arslan

the basic difference between in and exists

let's take the example of for loop in c++ and in loops when you write break statement it will iterates until the condition of break statement will true this like exist and in
if you didn't put break in it then it will execute the whole loop

Is This Answer Correct ?    7 Yes 7 No

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

Answer / raja

in operator returns the condition satisfied rows only

But in exists operator if any condition satisfied it will returns all the rows.

Is This Answer Correct ?    6 Yes 15 No

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

Answer / s. raban

see my answers

Is This Answer Correct ?    2 Yes 25 No

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

Answer / x

No Difference

Is This Answer Correct ?    5 Yes 126 No

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

Answer / santhosh

Spelling Different

Is This Answer Correct ?    13 Yes 146 No

Post New Answer

More SQL Server Interview Questions

What is microsoft sql server?

0 Answers  


what are different types of raid configurations? : Sql server database administration

0 Answers  


How to stop log file growing too big?

0 Answers  


Explain indexed views and partitioned view with their syntax.

0 Answers  


What is model database in sql server?

0 Answers  






What is t-sql script to take database offline – take database online.

0 Answers  


Table student containing 2 columns,Join date,Employee name. Under join date 4 rows r ter =1-jan-2008,2-feb-2008,3-mar- 2008,4-feb-2008.Under Employee name 4 difeerent names jaison,robin,binoy,rahul Result set is, Table containing 4-column name=jan,feb,mar,april,,beneath these months count is given as 1,2,1,0 means these counts representing number of emplooyees joined in a month(january 1employee,february 2 employee,march 1 employee,april 0 employee) Can you give me the required sql query

3 Answers   RND Soft, Wipro,


how would you write a sql query to compute a frequency table of a certain attribute involving two joins? What changes would you need to make if you want to order by or group by some attribute? What would you do to account for nulls?

0 Answers   Facebook,


Explain Geography datatype in SQL Server

0 Answers   Infosys,


How many columns can exist together per table?

0 Answers   Cap Gemini,


What is a cursor in SQL Server 2000 and their types?

8 Answers  


what is a live lock? : Sql server database administration

0 Answers  


Categories