Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Create table marks
(
MId int primary key,
TheoryMarks float,
Practical Marks float
)

Now i need to add a fourth column named ObtainedMarks as TheoryMarks+PracticalMarks.

This works with SqlServer.

How to do this?

What I have tried:

Create table marks
(
MId int primary key,
TheoryMarks float,
Practical Marks float,
TheoryMarks+PracticalMarks As ObtainedMarks
)
Posted
Updated 15-Jun-16 21:06pm

1 solution

Use a Generated Column[^] - it allows you to create a column which is an expression and either automatically set the value when the row is stored, or calculate it on the fly when you read it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900