I once had an SP which selected data from a table and presented them "pivoted". Since the number of columns in the pivot varied I created a statement in the SP and made EXECUTE( @var + @var2 + ... ). The SP executed at 5 seconds. Three of them due to 2 recompiles. (in spite of KEEP PLAN) According to Microsoft Support this is the behaviour you can expect from SQL server 7.

Then I created the statement in VB and sent it in to SQL server as dynamic SQL. It executes at .3 seconds.

Does anyone have the same experience? Does anyone know anything written about this?