Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using asp.net,c# and sql 2008 R2 in my project.

I came across a situation where I need to optimize my front end and back end .
I have a grid view with save and delete options.

Case :1 :-I can use either a single stored procedure with a parameter say @action ='Add' for save and @Action='Delete' for delete case .In the stored procedure I can handle these cases inside
if( @action=='Add')
...
else
.....


Case :2 :- i can use one stored procedure for save and another for delete.

Please advise which is the best method.

Thanks in advance.
Posted

1 solution

Use separate stored procedures. Just like in C# or any other programming language a method should have a single responsibility, your stored procedures should. For adding, you would usually have to supply multiple column values; for deleting usually only one. So if you used one stored procedure for both adding and deleting, you would have to supply but then ignore multiple values when deleting. That wouldn't be good practice. And having separate stored procedures for adding and deleting won't impact your performance at all.
 
Share this answer
 
v2
Comments
Member 10112611 23-Apr-15 3:52am    
Thanks you very much
Sascha Lefèvre 23-Apr-15 3:54am    
You're welcome.
Member 10112611 23-Apr-15 3:59am    
One more doubt..If I create 2 stored procedures memory consumption of the DB will be increased compared to the other option of using single ,right?. But on the execution side, instead of if... else... (which increases the execution time , i am not sure about this)it is better to use single one..Is it like that?
Sascha Lefèvre 23-Apr-15 4:08am    
You absolutely don't have to bother about memory consumption or performance. There won't be a difference significant enough to speak of. But separate stored procedures will be cleaner coding.
Member 10112611 23-Apr-15 4:08am    
Ok. Thanks..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900