I am writing stored procedures to retrieve data from an OLTP application that will be adding several hundred thousand transactions a day. The user will be presented a screen to select up to a dozen or so search criteria; date range, color, size, processing plant, etc. They may select all criteria, one or two, or none.
Currently I am creating a stored procedure "on the fly" by replacing temp vars with search criteria, compiling and executing.
My option would be to compile the stored procedure, pass it parameters, and run the precompiled stored procedure.
I am wondering, as the database is changing so much, if I am better off to compile the procedure every time it is run. Or if stored procedures are always the best way to go.
I plan to incorporate an update statistics in my maintenance plan with each night's back ups.