• bstauffer (6/16/2009)


    I got turned off by the apparent lack of understanding of how to use "IF EXISTS". Do you really think you need to do concatenation there??? You don't need to specify any columns in your SELECT when all you're doing is checking for EXISTS. "IF EXISTS(SELECT 1 FROM ... WHERE ...) will get you the same result, although with slightly better performance. When I start reading an "article" that shows this kind of lack of basic understanding I don't waste my time getting to the end of it. Who knows what kind of crap I could get stuck in my head if I wasn't careful.

    Seems like you've already got something stuck in your head that shouldn't be there (you're not alone though, as I've seen the above asserted many times before).

    There's no difference at all in performance between an Exists query with columns selected against that with a constant selected. Don't take my word for it -try creating yourself a wide & long table & see if you can spot the difference in performance & query plans between an Exists (Select *...) vs an Exists (Select 1...).

    It's true there's no functional difference, so the sole point of specifying anything inside the Exists clause is to aid understanding.

    I assume the performance issue was true at one point - I know it's not true of SQL 2005 at least, and I'm pretty sure it's not true for 2000 either. Anybody know where this stems from?