Instead of this:
IF (SELECT COUNT(*) FROM Table1 WHERE ... ) > 0
use this:
IF EXISTS(SELECT * FROM Table1 WHERE ...)
Great tip provided by this article.
You're reading the archived version of my blog at Blogger. Go to http://blog.macuyiko.com to stay up to date.