Home Forums SQL Server 7,2000 T-SQL Getting rid of dynamic SQL in this stored procedure RE: Getting rid of dynamic SQL in this stored procedure

  • Given the simplicity of the SQL I would simply duplicate the query on the other side of an IF.

    I've got something similar in some of my procs, but I have some really convoluted series of parameters.

    What I found was that trying to write a single SQL statement that encompassed all possibilities resulted in code that worked, but had a high cost.

    Breaking out the different functionality meant that the majority of users whose parameters triggered one of the simple query implementations got a very fast result without being penalised by those who triggered the more expressive queries.

    Sometimes the long way works better.