What are the pros and cons to keeping SQL in Stored Procs versus Code

Posted by Guy on Stack Overflow See other posts from Stack Overflow or by Guy
Published on 2008-08-18T19:54:39Z Indexed on 2010/06/08 9:22 UTC
Read the original article Hit count: 277

What are the advantages/disadvantages of keeping SQL in your C# source code or in Stored Procs? I've been discussing this with a friend on an open source project that we're working on (C# ASP.NET Forum). At the moment, most of the database access is done by building the SQL inline in C# and calling to the SQL Server DB. So I'm trying to establish which, for this particular project, would be best.

So far I have:

Advantages for in Code:

  • Easier to maintain - don't need to run a SQL script to update queries
  • Easier to port to another DB - no procs to port

Advantages for Stored Procs:

  • Performance
  • Security

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql