If we have a SELECT statement inside an IF EXISTS, does the execution stops as soon as it finds a record in the table? For an e.g.
IF EXISTS(SELECT *
WHERE Name='John' )
If a row exists in the table with the name =John, does it stops execution and returns 1 or does it traverses through the entire table looking for more matches?
@Tom and @Ryan,
Is there a better way to do the following:
IF EXISTS(SELECT * FROM t1 WHERE xxx AND yyy)
IF EXISTS(SELECT * FROM t1 WHERE xxx)
I have this inside a stored proc and the stored proc gets executed very often. My primary motivation is to improve the performance. I know I can use a constant 1 or 0 instead of a * in SELECT but the corresponding performance improvement is negligible