Thursday, September 26, 2013

Which is better, simple query or stored procedure to get data from sql server using c#?

This is a question for which there is probably no absolute "right" answer.


My opinion would be that stored procedures are generally better because they keep data access at the database level and allow the functionality that they provide to be shared between other software components. They also shift some of the work to the database server, (usually) improving effiency.


On the downside it can make any upgrade process a bit tricker if they need to be changed, and if your software supports multiple back-end databases they will likely need to be rewritten for each database.


On the other hand, if you are supporting a project that already uses queries written in code and they are presumably working, I would not consider it worth the effort or risk to go around changing an established piece of software!


No comments:

Post a Comment