Reputation: 249
I don't know when I should use stored procedure. I assume that I have the query like this:
select * from table A
Or
Update A set .....
Or
Insert into A...
Should I use stored procedure for the query like above or not. If not, so when should I use stored procedure?
I'm working on a big project and I'm a leader. At the moment, our website is well but I know that It will be die in the future. So I want to convert all complicated query to stored procedure, but I have to choose which query I should convert.
Upvotes: 1
Views: 882
Reputation: 5245
In 2014, for CRUD functions (INSERT - SELECT - UPDATE - DELETE
) you should use an ORM
to create a code representation of the data model.
If you need to perform a lot of complex SQL statements from a small set of input or if you you need to push thousands of records to SQL in a single statement, I would recommend you to use Stored Procedure.
Some people will probably talk about speed of stored proc. A decade ago, It was true about the speed but now, in most of time, there's no performance gain by using a SP
.
Take a look to that article: http://kevinlawry.wordpress.com/2012/08/07/why-i-avoid-stored-procedures-and-you-should-too/
Upvotes: 1