Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,128 | Comments: 45,549

filter by tags archive


Jeff Handley

Stored Procedures have their time and place.


While I was comparing to Linq to SQL, I imagine it would have been a LOT of effort to make any ORM perform the way the stored proc did in that case. And performance was a primary requirement for the task at hand.


Why are you against stored procedure?

As a rule, they are bad IMO in cases of abstracting simple select/insert/update, but for complex database operations I think they're quite useful

Not Alt

"Stored Procedures have their time and place."

Time = 1997

Place = Sql Server 7

Neil Mosafi

Definitely useful if your standard CRUD operations underperform. Can't see any other reason for them though, can you?

Steve Bohlen

We all eventually become the thing we hate; its as inevitable as the sun rising tomorrow :)

Ayende Rahien


Did you READ the post?

Mikael Lundin

I once found a stored procedure that returned html. The funny part was the TSQL logic that would set class attribute on a div depending on a query result.

But I guess we can't blame the technique for that mess. ;)


Well, if you've ever written a TSQL 'for xml explicit' query (multiple elements deep) you really start to appreciate stored procedures.

Calling them from an SQL Agent job performing cleanup and other maintenance tasks is another useful usage of stored procedures.



Yes. It seems to me that you're generally against them and this is a special case. I was asking why this is such a special case.


What's wrong with stored procedures? I usually write my data access code in stored procedures because it's much more efficient than calling SQL via .NET code and you have more control over the data through T-SQL functions etc.


To me it sound like it would be more interesting to know, not how you ended up in that position, but why your fellow team mate didn't ;) Especially in the view of the italic "I". Lack of dedication maybe?

Daniel Auger


You do realize Ayende is a contributor to NHibernate right?



one the worst perversities i've seen is from the offshore team that redesigned a web app at a former employer.

i was trying to create a webcontrol to integrate into the page pipeline, and i could not figure out where the HTML was being generated.

Turns out that the code called a stored procedure, which called a .NET assembly, which used ADO.net to query the database, which generated an XML string, which the assembly manipulated to produce HTML which the procedure returned to front end,

needless to say, im glad im gone.

Frank Quednau

Go, check out Gloria Gaynor's "I will survive" lyrics, exchange "you" with "stored procedure", add a salt of fantasy and you may have a chuckle or two..

Louis DeJardin

I guess that what they mean by "the exception that proves the rule"


Stored procedures have their uses. They can prevent users from batch updating or deleting the data. Sprocs also make it easier to work with data on linked servers or perform complex data logic when entities do not directly match to tables.

Buddy Stein
  1. Cleaner to use Linked server.

  2. Some queries can be better optimized (read run faster) in stored procs than .net code or Linq to Sql. A good DBA can do miracles increasing performance in complex queries.

  3. Easy to modify the data access without re-compiling code.


If you're using sprocs because your CRUD underperforms then your code or database likely needs refactored.

Nuno Lopes

Unless ORM and IoC are religions I don't understand the first post :) We all know that a good programmer simply uses or builds the best tool to solve a problem.

I guess the post is for us to do some guess work.

So here it is one:


Nuno Lopes

Kristoffer Sheather

No one has provided a hypothesis for how Ayende ended up in this position yet. Personally I'm not sure how either, but I'd sure be interested to hear the back story.


Very rarely sprocs will give you any real performance benefits while making things much more complecated for developer team.

Comment preview

Comments have been closed on this topic.


  1. The worker pattern - 2 days from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats