title: Storing formula (equations) in database to be evaluated later (SQL Server 2005)
body: <p>I'm calculating linear regressions based on a data set. I do not know the regression model or number of parameters at compile-time.</p>
  
  <p>I'm storing the regression equation in a SQL Server 2005 database as the string </p>
  
  <pre><code>y = 3x^2 + 2x // just an example
  </code></pre>
  
  <p>When I need to make a prediction, I grab the equation from the database, substitue <code>x</code> with the value I'm predicting, and use <a href="http://ncalc.codeplex.com/" rel="nofollow">NCalc</a> to evaluate the resulting string.</p>
  
  <p>That method seems to work OK, but I'm wondering if there's a better way or a built-in feature of SQL Server that I've missed that would allow me to do these calculations <strong>on the database side</strong>.</p>