September 6, 2008 at 3:00 am
I have a column c1 in a table T1, there is another table t2 with column c2.
I am required to prepare a formula for a computed column in t2.
Formula will check that if c2 is less than c1 then computed value will be 0, and if c2 > = c1 then computed value will be 1.
How to prepare such formula with join between t1 and t2.
DBDigger Microsoft Data Platform Consultancy.
September 6, 2008 at 6:49 am
Hello,
You would probably want to create the Computed Column from a Case statement based on column c2, with the if/else logic comparing it to column c1.
Regards,
John Marsh
www.sql.lu
SQL Server Luxembourg User Group
September 6, 2008 at 8:11 am
A computed column cannot be used as defining expression may only reference base columns within the same table.
You will need to add a physical column and then use a trigger to maintain the value.
SQL = Scarcely Qualifies as a Language
September 6, 2008 at 6:04 pm
Like Carl said... can't be done by a computed column... but, you could use a view for this. Carl also suggested that you could use a trigger and that would work, as well.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply