Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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: Thursday, April 10, 2014 8:04 AM
Points: 116, Visits: 337
My devs seem to use sp_execute even for the execution of SPs. Is there any downside to this dynamic model?

SQL Pizza

sometimes you dont see the pizza for the toppings...
seek and ya shall find...
Post #1445477
Posted Wednesday, April 24, 2013 4:42 AM



Group: General Forum Members
Last Login: Yesterday @ 4:48 AM
Points: 14,802, Visits: 27,278
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 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
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: Wednesday, April 16, 2014 9:25 AM
Points: 7,070, Visits: 12,523
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1447059
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse