title: Using SET statement in a select query
body: <p>This is my scenario. I have a stored procedure that has a select query. </p>
  
  <pre><code>Select M ,X , Y, dbo.function(parameters) as Z 
  from SomeTable 
  where condition1 
  and condition2 
  and Z &gt; SomeValue
  </code></pre>
  
  <p>the Z in the where clause is the calculated value from the function.</p>
  
  <p>The dbo.function returns a single value always. </p>
  
  <p>I dont want to use the function in the where clause. I want to set the value to a variable and use that variable in the where clause. </p>
  
  <p>How should this be done? kindly help.</p>