title: How to create a computed column that references another column from another table?
body: <p>I am using Microsoft SQL Server and I am still learning. I have two tables, a product table and an order details table. The product table contains a price and then the order details table has a reference to the the product, the quantity of the product and the total price. Here are the two tables:</p>
  
  <pre><code>--Create Product Table
  CREATE TABLE Products.Product  
  (
      product_id          INT             NOT NULL    PRIMARY KEY IDENTITY,
      product_name        VARCHAR(40)     NOT NULL,
      product_desc        VARCHAR(5000),
      product_price       SMALLMONEY      NOT NULL    CHECK (product_price &gt;= 0)
  );
  
  --Create Order Details Table
  CREATE TABLE Orders.Order_detail 
  (
      order_detail_id     INT             NOT NULL    PRIMARY KEY IDENTITY,
      product_id          INT             NOT NULL,
      product_quantity    INT             NOT NULL    CHECK (product_quantity &gt;= 0),
      order_detail_total  MONEY           NOT NULL,
  
      FOREIGN KEY (product_id)        REFERENCES Products.Product
  );
  </code></pre>
  
  <p>How can I make it so that order_detail_total is a computed column that is the <code>product_price * product_quantity</code>?</p>