title: SQL stored procedure passing parameter into "order by"
body: <p>Using Microsoft SQL server manager 2008.</p>
  
  <p>Making a stored procedure that will "eventually" select the top 10 on the Pareto list.  But I also would like to run this again to find the bottom 10.</p>
  
  <p>Now, instead of replicating the query all over again, I'm trying to see if there's a way to pass a parameter into the query that will change the order by from asc to desc.</p>
  
  <p>Is there any way to do this that will save me from replicating code?</p>
  
  <pre><code>CREATE PROCEDURE [dbo].[TopVRM]
  @orderby varchar(255)
  AS
  SELECT Peroid1.Pareto FROM dbo.Peroid1
  GROUP by Pareto ORDER by Pareto @orderby
  </code></pre>