Microsoft SQL Server Management Studio, automatically filling a field with values from another field? -


I create the following code on the DZin for the database, but I hope that it does not work, this tables and all Some builds seem to work properly, as long as I enter the information in the ORDERDETAILS table, I need to fill the field "UNITPRICE" from the table with values ​​stored in the "UNITPRICE" field automatically "ORDERDETAILS" from the "PRODUCT" table Is there any way to achieve this goal? For Mitigation? Create a table [product] ([productId] NUMERIC identity (1,1) No NULL, [pRODUCTNAME] VARCHAR (40), [UNITPRICE] double PRECISION no zero, [unitsInStock] integer, Constraints [PK_Products] Primary key ([productId], [UNITPRICE]) Table [ORDERDETAILS] ([OrderID] NUMERIC IDENTITY (1,1) NO NO, [productId] Numeric No NULL GO, [UNITPRICE] Double PRECISION NO NULL , [Bid [Option], [Product ID], [UNITPRICE]) GO ALTER Table [ORDERDETAILS] Obstacle [Products_OrderDetails] Foreign Add Keys ([productId], [UNITPRICE]) Reference [Product] ([productId] ], [UNITPRICE]) GO

Thanks in advance.

You might use an INSERT trigger, but why do you want to do this?

If you were going to find the price, do not you want to make an inclusion between the order and description and the product table, depending on the product ID of the item?

  ORDERDETAILS select od.productId = p.productId  
on the OD as p.unitprice JOIN As Product P

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -