advantages and disadvantages of using direct sql querying in application could people please give their opinion on and give advantages and disadvantages on the use of sql queries directly within an application as opposed to creating procedures or functions within the database and using them.
Raw SQL


A good inline SQL query, if made correctly using parameters  is as
good as a stored procedure.
Raw SQL is  more flexible to deal with.



Stored procedures


Stored procedures have the benefits of security , but just raw
performance isn't one of their major plus points.
Stored procedures are more maintainable.
Stored procedures are precompiled
The security and data layer separation benefits and increased ease of
performance tuning provided by strictly using stored procs generally
make them a better solution than ad-hoc queries regardless of any
relative performance enhancement that may or may not come with the
pre-compilation of the procs.
scalability and modularity


Conclusion

I'd personally like to utilize only Stored Procs for database access.
The only thing I see SQL doing that stored procs can't do (easily) is dynamically choosing the sort order. Other than that, it's about knowing how to code the stored procs the way you need.