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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Create Derived Column
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aademeo
Starting Member

5 Posts

Posted - 09/16/2014 :  20:46:19  Show Profile  Reply with Quote
I'm working on creating a table in SQL where one of the columns is a derived attribute. Need to declare an attribute called CourseDurationYears, which is derived by the total number of years since the CourseStartDate.

Student_Courses
StudentCoursesID
StudentID
CourseID
CourseStartDate
CourseComplete

CourseList
CourseID
CourseDescription
CourseCost
CourseDurationYears
Notes

Below is what I have so far, but I'm stuck on the CourseDurationYears. Not sure what to declare as the datatype or how to correctly have it reflect the derived value:

CREATE TABLE Student_Courses
(
StudentCoursesID INT NOT NULL IDENTITY(1,1),
StudentID INT NOT NULL,
CourseID INT NOT NULL,
CourseStartDate DATETIME NOT NULL,
CourseComplete DATETIME NULL
);

CREATE TABLE CourseList
(
CourseID INT NOT NULL IDENTITY(1,1),
CourseDescription VARCHAR(255) NOT NULL,
CourseCost MONEY NOT NULL,
CourseDurationYears DateTime(YYYY) NOT NULL,
Notes NTEXT NULL
);

khtan
In (Som, Ni, Yak)

Singapore
17689 Posts

Posted - 09/16/2014 :  20:51:37  Show Profile  Reply with Quote
Why is the CourseDurationYears in CourseList table is depend on the CourseStartDate of Student_Courses ?




KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000