Hi,I pointed out to a fellow developer of mine a few days back that I though his use of EXISTS was really pointless and I asked why e wasn't using joins instead. He told me that EXISTS was faster but I didn't belive him so a made a simple test:DECLARE @table1 TABLE (ID1 INT PRIMARY KEY CLUSTERED, Value1 varchar(200))DECLARE @table2 TABLE (ID2 INT PRIMARY KEY CLUSTERED, Value2 varchar(200))SELECT a.* FROM @table1 a INNER JOIN @table2 b ON a.ID1 = b.ID2WHERE Value2 > 10SELECT * FROM @table1 a WHERE EXISTS ( SELECT ID2 FROM @table2 b WHERE ID2 = a.ID1 AND Value2 > 10)
These two queries however give the exact same execution plan, so our argument is now at a standstill. Will either of the two give any performance gains over the other in difefrent scenarios?--Lumbago"Real programmers don't document, if it was hard to write it should be hard to understand"