title: Filter SQL query based on scalar function result
body: <p>In SQL Server, I can't seem to use an aliased column name in the <code>WHERE</code> clause</p>
  
  <p>This doesn't work </p>
  
  <pre><code>SELECT *, [dbo].[myFunc] (X.Prop1) AS Width 
  FROM X 
  WHERE Width &gt; 0
  </code></pre>
  
  <p>I have to do</p>
  
  <pre><code>SELECT *, [dbo].[myFunc] (X.Prop1) AS Width 
  FROM X 
  WHERE [dbo].[myFunc] (X.Prop1) &gt; 0
  </code></pre>
  
  <p>My concern is that SQL is executing <code>[dbo].[myFunc] (X.Prop1)</code> twice.</p>
  
  <p>My questions are:</p>
  
  <ul>
  <li>Is it executing twice or is SQL Server smart enough?</li>
  <li>Is there a way to use an aliased column in the <code>WHERE</code> clause?</li>
  </ul>