title: Dynamic SELECT TOP @var In SQL Server
body: <p>How can I have a dynamic variable setting the amount of rows to return in SQL Server? Below is not valid syntax in SQL Server 2005+:</p>
  
  <pre><code>DECLARE @count int
  SET @count = 20
  
  SELECT TOP @count * FROM SomeTable
  </code></pre>