Blog - Single Post

Never do in code, what you can get the SQL Server to do well for you

  • Wednesday, January 28, 2015
  • by hbopuri

When should one consider to perform database specific operation in your code base?

RDBMS are build to handle a common data storage and manipulation operations such as:

  1. Joins
  2. Filtering Data
  3. Selecting
  4. Aggregating Data
  5. Relationship Integrity

believe it or not some architectural practices force you do all the above in code base with tons of lines of code with no added value.

Advantages of Stored Procs

  1. Stored procedures give you code reuse, and encapsulation - two pillars of software development
  2. Security - you can grant/revoke permissions on an individual stored proc
  3. Protects you from SQL injection attacks
  4. Help with speed

One false assumption in most of the above architectures styles is, data always being accessed via application, which is not true with modern ORM frameworks/Technology, such as:

The intention behind inventing/discovering SQL Server is to delegate much of the heavy lifting to the SQL Server (for things it is good at) and reduce the amount of Application Server/ IO as much as possible and let SQL do the job and returning smaller data set.