title: How to automate or create a scheduled Job for the below query in SQL Server
body: <p>I am having the following query to check whether any data is stored in SQL Cache</p>
  
  <pre><code>select er.*, st.*
  from sys.dm_exec_requests er
  cross apply sys.dm_exec_sql_text(er.sql_handle) st
  where st.text not like '%C7DB%' -- filter self
  GO
  </code></pre>
  
  <p>From the above query I need to pick the <code>Plan_Handle</code>(if any present) and run the 2nd query to clear the SQL Cache</p>
  
  <pre><code>DBCC FREEPROCCACHE (0x060007002D2BE10840E13F38030000000000000000000000);
  </code></pre>
  
  <p>I need to run this manually every 30 mins. </p>
  
  <p>Can you please suggest, how to automate this process</p>