views:

94

answers:

4

Background: I use stored procedures exclusively for an ASP.NET application. I am using a DataReader to load a dataset object.

+1  A: 

IMHO a single multiple-result stored procedure will perform better as only a single network roundtrip to the SQL server will be performed.

Darin Dimitrov
+1  A: 

If it is a single dataset I would be using a single SP and have your SP return exactly what your dataset needs. It will be faster and more secure to have the SP do that work for you and one call for the connection would be more efficient than calling multiple times to load a single dataset.

Matt
I use the same strategy wherever possible. +1.
David Stratton
A: 

Returning all of your data in a single query is almost always better, unless that puts too much onus on the app to manage the shape of that data. Of course, if your returning millions of rows, you'll probably want to break that up into something a little more lazy if possible :)

ThatSteveGuy
+3  A: 

Single procedures returning single results (for code maintenability, simplicity and reuse of procedures) and then have one single call invoke all procedures needed:

command = new SqlCommand(@"
exec usp_proc1 @param1, @param2;
exec usp_proc2 @param1, @param3;
exec usp_proc3 @param2, @param4;");

Or you can create a wrapper procedure that simply invokes the individual procedures and call the wrapper. Overall, I say that the advantage of one round-trip is too good to be ignored.

Remus Rusanu
This type of solution ended up being a big help that I could implement quickly to speed up stored procedure execution time. I learned this trick in an answer to my question [What’s a good alternative to firing a stored procedure 368 times to update the database?](http://stackoverflow.com/questions/3282254/whats-a-good-alternative-to-firing-a-stored-procedure-368-times-to-update-the-da)
Ben McCormack
Interesting read. CLR is not the direction I want to have to migrate to yet, however.
subt13
There is no CLR usage in the answer from @Remus Rusanu. You could drop this in as a replacement to for-eaching the sproc calls.
Aaron D