• Marcin Gol [SQL Server MVP] (9/11/2009)


    in case of exists/no exsits - it is the only place where you can use star without loosing performance and maitainability

    ...COUNT(*) versus COUNT(1) is the other example.

    Star versus constant or NULL - it makes no difference in modern SQL Engines. DB2 and Oracle had a preference for indexes columns and constants respectively way way way back in the day, but no longer.

    I don't expect anyone to take my word for it though. * shrug *

    Some people prefer not to use SELECT * since it makes searching for dumb uses of the construct harder.

    Some people prefer SELECT * because it mirrors the COUNT(*) idea.

    Some people prefer SELECT * because SELECT [constant] is so arbitrary.

    I like star.

    I find COUNT(1) particularly amusing since the XML query plan still shows the operation as "count_star" 😀

    ...EXISTS (SELECT NULL seems confused to me.

    ...EXISTS (SELECT 42.9853 seems peculiar, but equivalent to using 1 or 0 or whatever.

    Paul