Stored Procedures vs Ad Hoc SQL

Stored procedures debate from my point of view:

Pros of using Stored Procedures

Cons of using Stored Procedures

I’m not entirely sure which side of the fence I lie.  Right now I’m more comfortable with not using stored procedures because of the maintenance factor.  I really think LINQ is going to make stored procedures deprecated.

.NET specific - Here is a nice line of code to keep around when working with stored procedures that I end up using when getting the the dreaded “Parameters do not match” error.  You can put this on your datasource Inserting Event.

For x As Integer = 0 To e.Command.Parameters.Count - 1

Trace.Write(e.Command.Parameters(x).ParameterName)

Trace.Write(e.Command.Parameters(x).Value)

Next

Written by Tim on June 1st, 2007 with 3 comments.
Read more articles on asp.net and database.



Related articles

3 comments

Read the comments left by other users below, or:

Get your own gravatar by visiting gravatar.com Corwin
#1. July 26th, 2007, at 7:06 PM.

You can create test harnesses to test/debug the procs. And if you include tons of commmented out tests in the harness, you can easily retest portions as needed. Stored procs should contain an error handling routine that passes back something better than 512.

Embrace it, logic in the database is a good thing.

Get your own gravatar by visiting gravatar.com Andrew J. Lazarus
#2. December 5th, 2008, at 5:20 AM.

Stored procedures are naturally resistant to SQL injection malicious attacks. Rolling your own is not. Of course, if your queries are not dependent on (possibly malicious) user input, this is moot.

Get your own gravatar by visiting gravatar.com software development london
#3. October 15th, 2009, at 3:28 PM.

That was inspiring,

interesting post, keep up the good work,

Thanks for writing, most people don’t bother.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .