Unix Technical Forum

sp_executesql vs. stored proc.

This is a discussion on sp_executesql vs. stored proc. within the SQL Server forums, part of the Microsoft SQL Server category; --> Greetings All, currentley there is a heated discussion in my place of work over which method is better/more efficient ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 06:23 AM
LineVoltageHalogen
 
Posts: n/a
Default sp_executesql vs. stored proc.

Greetings All, currentley there is a heated discussion in my place of
work over which method is better/more efficient for simple selects.

Background:
1.) Simple Application that uses sql server for backened db.
2.) The application is only inserting and selecting data from the db.
3.) The developers want to use sp_executesql for simple selects and
the dba's want to use a stored proc.

>From my reading it seems that sp_executesql has a bit of overhead with

it and it is not as efficient as stored procs.

I would appreciate anyone's input on which would be better for simple
repetitive inserts to the db: Stored Proc, or sp_executesql?

Regards, TFD.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 06:23 AM
Greg Gilman
 
Posts: n/a
Default Re: sp_executesql vs. stored proc.


>>From my reading it seems that sp_executesql has a bit of overhead with

> it and it is not as efficient as stored procs.


If your developers are arguing for sql statements and your DBAs are for
stored procs, where did you get sp_executesql?

Typically sql statements are just sent by the application to the server,
without the use of sp_executesql. The situation where sp_executesql
would be used is if you had to dynamically generate a statement on the
server, you would build the statement in T-SQL, assign it to a variable,
and then execute it, so I don't think it's relevant here.

Getting back to your question, stored procs will almost always be
faster. SQL server caches the query plan and reuses it, making them
very efficient. There are other advantages too, like being able to
update the queries without recompiling your app, or touching the sql
generated by your developers. Since you obviously have people dedicated
to development and to database administration it seems you would get the
most benefit from stored procs. The developers can focus on code,
without having to worry about getting their sql right, and the DBAs can
focus on tuning those stored procs.

Greg Gilman
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:22 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com