Dynamic merit/demerit | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Dynamic merit/demerit

Hi All,
In my SP i create dynamic temp object and fires select and then drops it as below. set @sqlcmd=’select * from ‘[email protected]
exec sp_executesql @sqlcmd set @sqlcmd=’DROP TABLE ‘[email protected]
exec sp_executesql @sqlcmd
Instead of above two statements, what gain/loss i will get if i change it to only one statement: set @sqlcmd=’select * from ‘[email protected] +’ DROP TABLE ‘[email protected]
exec sp_executesql @sqlcmd
Nothing much either way. You have two instructions that will be executed one after the other, whether you feed them in a single batch instruction or in separate instructions. So there will be a very small increase in processing time for the script, but nothing you would notice for the processing time for the instructions per se.