title: sql server sort by first column in table
body: <pre><code>exec ('select * from variable_table_name
  order by @variable')
  </code></pre>
  
  <p>I'm trying to put together a dynamic sql statment where you specify a table name and sort column. It would be nice if I can just specify a table name to make the sql work. </p>
  
  <p>Is there a way to choose the first column of a table to sort by if @variable sort by not specified?</p>