• eddy-644184 (2/20/2010)


    Didnt know that about the select * vs the select Key

    But i try to minimize the use of select *, so its kinda a habit for just typing what i really need 😀

    I tend to write EXISTS (SELECT 1 FROM SomeTable ...), to make it clear that no columns are returned or necessary

    Could you just confirm my statement on the use of select TOP 1 @PARAM = Value or am i wrong there .?

    It'll work without the TOP 1, if the query returns more than 1 row, you'll get one of them, it isn't guaranteed which one. But then, if you use TOP 1 without an order by, it isn't guaranteed which one you'll get either.

    SET @var = (SELECT value FROM ...) will throw an error if the query returns more than one row.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass