title: SQL Server: how to do math calculations in a string?
body: <p>I have an application that allows calculations on input data before writing it to a table. </p>
  
  <p>None of the calculations can be done in C#, all must be done in T-SQL. </p>
  
  <p>The application builds an insert statement with possible nested calculations based on user input.</p>
  
  <p>One sample is an integer that is divided by 10 and then cast to <code>varchar</code>.</p>
  
  <pre><code> CAST(( ' ( CAST( 6828 AS BIGINT)) /10' ) AS NVARCHAR(MAX)) ,
  </code></pre>
  
  <p>This is part of a larger INSERT statement that is built based on user interface input.</p>
  
  <p>How would I get the inner part <code>( CAST( 6828 AS BIGINT)) /10</code> executed first?</p>