msimone - Thursday, February 1, 2018 8:59 AM
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