Saturday, September 15, 2007

SQL: Check Existing Rows Matching A Condition

Instead of this:

IF (SELECT COUNT(*) FROM Table1 WHERE ... ) > 0

use this:

IF EXISTS(SELECT * FROM Table1 WHERE ...)

Great tip provided by this article.