Hello,
I have scheduled a recompile for few of my procs like this exec sp_recompile [proc_name].
I want to do the same thing with an adhoc query, currently I manually re-compile it in case of any issues by using dbcc freeproccache(plan_handle) however I want to automate it and regularly clean the plan cache of the adhoc query.
P.S I believe optimisation is a long term resolution however in this case the adhoc query is scheduled to be deprecated in few weeks and I don't want to spend much of my time in optimising it.