• stevanuz (10/22/2010)


    thanks all for the comments.

    the use of the stored procedure 4 this solution might seem not so obvious but i do personally prefer sp instead of ad-hoc launched from data access since its easier to maintain; so i believe it's not about right or wrong or over-complicate things but about preferences.

    I think this may be an example of taking a good idea (encapsulating logic in a stored proc) and applying it without consideration of whether it is appropriate in the specific circumstance. If you want to encapsulate the logic, I'd suggest creating a centralized count method in your code that builds the SQL. You take on a lot of baggage using dynamic SQL that could create unintended side effects (for example permission and scope issues) with no benefit on the other end of that trade-off.