After having this discussion with a colleage I'm looking for more opinions. From a programming standpoint, why would on always use a stored procedure over a sql select statement. What are the pros and cons of each?
If the point of writing the procedure is to only select a field or two from the database and based on the results return alternate values (ie, if userallowed='Y' return 4). Why do that in a procedure when in a program you could also execute that SQL select statement and then you have the field values to then run your own if statements on. Why one over the other? Is it best to write procedures for ANY SQL statement so that SQL statements NEVER appear in code only procedures get written?
If the point of writing the procedure is to only select a field or two from the database and based on the results return alternate values (ie, if userallowed='Y' return 4). Why do that in a procedure when in a program you could also execute that SQL select statement and then you have the field values to then run your own if statements on. Why one over the other? Is it best to write procedures for ANY SQL statement so that SQL statements NEVER appear in code only procedures get written?