Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Excessive sp_executesql usage Expand / Collapse
Posted Tuesday, April 23, 2013 8:34 AM



Group: General Forum Members
Last Login: Tuesday, December 1, 2015 7:54 AM
Points: 134, Visits: 454
My devs seem to use sp_execute even for the execution of SPs. Is there any downside to this dynamic model?

Query Shepherd
Post #1445477
Posted Wednesday, April 24, 2013 4:42 AM



Group: General Forum Members
Last Login: Yesterday @ 6:22 AM
Points: 17,171, Visits: 32,132
As long as they are calling procedures or creating parameterized queries, not really. It might tend to bloat the cache a little depending on how the calls are generated since additional statements around the EXEC sp_executesql could be stored there. That would be my one concern once I was sure they weren't just generating ad hoc T-SQL.

"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server Query Performance Tuning
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1445849
Posted Friday, April 26, 2013 9:19 AM



Group: General Forum Members
Last Login: 2 days ago @ 3:25 AM
Points: 7,933, Visits: 14,355
As a side note, using sp_executesql is pretty much how every query from SMO (objects used by SSMS) is issued against the instance. The SQL Agent team coded their queries this way as well and they did a lot of things wrong initially and it did result in plan cache bloat. If you run a Trace on your instance and then navigate around the Object Explorer in SSMS and run a few SQL Agent jobs you'll see what I mean.

There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1447059
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse