title: TSQL - how to execute a query as a variable?
body: <pre><code>DECLARE @query as varchar(200);
  SET @query = 'SELECT COUNT(*) FROM table';
  </code></pre>
  
  <p>How can I execute <code>@query</code>, and additionally, is there way to store the query result directly when assigning the variable?</p>