title: Table Name Includes Date
body: <p>Sorry for any incorrect terms as I am not proficient in SQL...</p>
  
  <p>I have a query that I need to run daily, however the table that I need to query includes todays date.  Normally I run: </p>
  
  <pre><code>SELECT m.displayName, a.source, count(a.agentGuid)
  FROM ntEventLog20120725 AS a
  LEFT OUTER JOIN machNameTab AS m ON a.agentGuid = m.agentGuid
  WHERE a.eventTime &gt; DATEADD(hour, -1, CURRENT_TIMESTAMP)
  GROUP BY a.agentGuid, m.displayName, a.source
  HAVING COUNT(a.agentGuid) &gt; 1000
  ORDER BY m.displayName
  </code></pre>
  
  <p>However the table I want to query each day is different.  Todays table is <code>ntEventLog20120725</code>, tomorrows will be <code>ntEventLog20120726</code>.  I know how to get the date in that format:</p>
  
  <pre><code>SELECT CONVERT(varchar, getDate(), 112)
  </code></pre>
  
  <p>I just do not know how to combine the two together so that I can schedule this to run everyday.</p>