title: Desired number of result rows as parameter in stored procedure
body: <p>I'd like to allow my consumer to specify the number of rows they want returned in a stored procedure.  I'm looking to mimic this behavior:</p>
  
  <pre><code>SELECT  TOP 100 AccountId ,
          AccountName
  FROM    dbo.Account
  </code></pre>
  
  <p>But in this fashion:</p>
  
  <pre><code>DECLARE @resultCount INT = 100;
  
  SELECT  TOP @resultCount AccountId ,
          AccountName
  FROM    dbo.Account
  </code></pre>
  
  <p>Of course the 2nd version results in an "Incorrect syntax near @resultCount" error.  Is there a way to do this without breaking down to contatenating SQL strings and using EXEC?  I find that is not very maintainable.</p>