title: Calculate Total Price based on Info in other Columns in SQL
body: <p>I'm using SQL Management Studio to create a database. I have a table named Items with the following columns:</p>
  
  <pre><code>ID    Product Name  Original Price     Discount Price   Shipping Price   Tax  Total Price
  </code></pre>
  
  <p>For now I am just adding arbitrary product names and original prices. What I want to do is have my Total Price column do something similar as Excel where, given an Original Price, a Discount Price, Shipping Price and Tax, I can create a formula in Total Price so that if any other prices ever change, the Total Price is computed automatically. I don't know how to do this, but I've tried to create a function and then call the function in my INSERT VALUES statement:</p>
  
  <pre><code>CREATE FUNCTION dbo.CalculateTotal()
  RETURNS money;
  AS
  
  BEGIN
  DECLARE @totalPrice int;
  SELECT @totalPrice = ((Original Price - Discount Price) + Shipping Price) + tax
  FROM dbo.Items
  Return @totalPrice
  
  END
  </code></pre>
  
  <p>Then I inserted the method:</p>
  
  <pre><code>  INSERT INTO dbo.Items VALUES('00000', 'Laptop', $200.00, $20.00, $4.99, $5.49,   dbo.CalculateTotal())
  </code></pre>
  
  <p>However, that did not work. The datatype I used for all the prices is the money data type. How can I calculate the Total Price? Thanks in advance.</p>