Reputation: 3743
i have two table in sql serever with no relation 1-rate table 2-jewellry tabale rate table hold diffrent rate for example usd , gold , platinume and jewellry table use holds jewellry item , and total price of each item is calculated real time based on rate value from rate table .
price field in jewellry table is computed column and has its own business rule , but in end it should use a value in rate table to complete the rule , for example gold rate in rate table*weight(jewellry table)*tax(rate table ).
how can i achive this in sql server ? store procedure ? function ? i dont want to use any client side because i want to export table via wcf as odata .
Upvotes: 0
Views: 76
Reputation: 1280
You can just use columns are contained in current table. For your purposes you can use triggers on foreign table for total sum calculation. Or you can use views for aggregation total results.
Upvotes: 1
Reputation: 1269503
You can achieve this by creating a user-defined function that does the calculation that you want.
The computed column can then be set using the UDF.
Upvotes: 1