Hi jvdub22, below is an example of a computed column see this line [DORetirement] AS (dateadd(year,(60),[DOBirth])-(1)) PERSISTED remember this is all accomplished in the data base, I often use scalar vaued functions and pass in some (i.e.
value PK or FK column) and then access related tables for the values.
USE [AdventureWorks]
GO
-- Create Table with computed column
CREATE TABLE [dbo].[CCtest]
(
[empNumb] [int] NULL,
[DOBirth] [datetime] NULL,
[DORetirement] AS (dateadd(year,(60),[DOBirth])-(1)) PERSISTED
)
GO
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
jvdub22
Member
2 Points
13 Posts
Re: Displaying other columns from the related foreign key table
Jan 16, 2013 04:05 AM|LINK
sjnaughton,
can you show me an example of the computed columns?
thanks
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: Displaying other columns from the related foreign key table
Jan 16, 2013 07:49 AM|LINK
Hi jvdub22, below is an example of a computed column see this line [DORetirement] AS (dateadd(year,(60),[DOBirth])-(1)) PERSISTED remember this is all accomplished in the data base, I often use scalar vaued functions and pass in some (i.e. value PK or FK column) and then access related tables for the values.
Always seeking an elegant solution.