The 'benchmark' code
I've decided to post the code I used to test what's faster: dynamic queries or stored procedures with optional parameters. The code can be found here. Let me add a disclaimer here, that I'm not pretending to have done scientific research or other scientific benchmarking. All I've done is wrote a couple of routines which represent for me a real life situation using either one of the techniques. Of course the routines can be sped up and recoded in other forms, and perhaps I've made a mistake in the code which results in the slow speed of either one of the used techniques. Feel free to comment :)