• msimone - Thursday, February 1, 2018 8:59 AM

    The idea is that procedures return one row or all, simple idea for a simple example.

    That is a really, really bad idea.
    Write procedures that do one thing and one thing only (single responsibility principle). So one procedure to fetch a filtered row. A different procedure to return all rows. No parameters for TOP, no weird dynamic SQL.

    If  you try to do both in one procedure, I promise you it will be a performance nightmare.

    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