title: sql server store the result of a select in a variable?
body: <p>I am making a function. A select statement returns only one row with one column, say an int. How do i store this int inside a declared variable so that my function can return the variable ?</p>
  
  <pre><code>select sum(table_name.col1) -- this line returns only one int. How to store that
  --in a declared variable ? 
  from
  (select 
  col1, col2
  --code here
  )table_name
  </code></pre>