SQL query in the application code vs. stored on the SQL Server

Tags:
Development
SQL Server
Hi, I am a DBA with a developper background. I always prefered to store my queries on the SQL Server. Which are the pros and cons of keeping the queries in the application code and storing them on the SQL Server? Thanks
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Storing queries on the SQL server in the form of stored procedures allows for much easier maintenance. As long as the data returned to the application is in the same result format as it expects, the stored procedure can be updated at the server level, and all applications referencing that procedure will automatically receive the query modifications. No code update is necessary unless columns are added or types changed. Also, SQL Server stored procedures are compiled by default, so the query execution plan does not have to rebuild if the parameters are the same. This can add a lot to performance.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: