My needs are very similar to this question about where to store business logic and this question about managing SQL code in a data table. But I would like more specific tips on how to manage the risks of SQL injection and Sandboxing that are alluded to in the answer to that second question.
My applications deal with data submissions that involve thousands of validation rules which need to be updated frequently. I would like to manage these rules as error conditions (formatted as SQL "WHERE" clauses) stored in a data table (ex: "Total != Column1 + Column2"). I would like analysts skilled in SQL to have access to directly insert and update these business rules, either in Management Studio or through an intranet application. One or more intranet applications or SQL processes would then use the error clauses in that table to validate data stored in other tables in the database.
Is it fundamentally a bad approach to save arbitrary code to a database, even if access to that table is restricted to a small number of users?
As my applications execute SELECT statements using the retrieved WHERE clauses, is there an effective, reliable way to limit the access rights of any malicious code pulled from the database? (I'm not confident that I can reliably sanitize a retrieved WHERE clause.)
Is there a better place to store frequently updated business logic, that is similarly simple to manage, but with better security?
Where can I go to find general principles about managing executable code in a database?