Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Calculated columns

Author  Topic 

aidmondo
Starting Member

23 Posts

Posted - 2012-05-12 : 15:51:54
Can a column A of table 1 = a column B of table 2 * column C of table 3?
If yes how?

Eg.

Create table EventType
(
EventTypeId int CONSTRAINT cpkET PRIMARY KEY,

ChargePerPerson money not null

)

Create table Events(

EventID int CONSTRAINT cpkE PRIMARY KEY Identity(1,1),

NoOfPeople int not null

)

Create table Payments(

PaymentID int CONSTRAINT cpkPay PRIMARY KEY,

PaymentAmount money

)

Can the PaymentAmount=ChargePerPerson * NoOfPeople?

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-05-12 : 15:58:24
Computed column in the conventional sense of the term used in SQL server can use only columns from the same table. So what you want to do cannot be done as a computed column. You might be able to create a view that joins the tables and has the additional column.

One question to ask before you do this is: how are tables B and C related?
Go to Top of Page
   

- Advertisement -