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
 Two columns having always same value

Author  Topic 

thealley
Starting Member

5 Posts

Posted - 2008-02-10 : 12:39:08
Hello,

Can you have two columns set to always contain the same value for an item in column 1 (without creating a new relation). I mean if in, say, column Lessons you have a lessonID showing more than once, you want that the date in column LessonDate will always be the same for the respective lesson.

Thanks mates!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-10 : 13:09:36
This is implemented by keeping a seperate table for Lessons with LessonID being its primary key. There each Lesson record will have a attribute called LessonDate which is always same for a particular lesson. Then wherever we want this lesson attributes we just include this LessonID in the relevant table with foreign key set to Lessons table. While retrieving results, we join with lessons table on LessonID to retrieve the date & other attributes ( which is always unique for a particular LessonID).As far as LessonID is same within records in our table, the date & other attributes brought by joining to Lessons table will be same. Hope this is exactly what you want.
Go to Top of Page

thealley
Starting Member

5 Posts

Posted - 2008-02-10 : 16:45:21
Hello visakh16,

Thanks for your reply. Actually however I wanted something without creating a new table. I don't know if that's possible with triggers or something else....

Go to Top of Page
   

- Advertisement -