I need to write a SQL query to update Age
column from a DateOfBirth
column. Below is a sample table with some ready data.
CREATE TABLE Students
(
ID INT IDENTITY,
Name VARCHAR (100),
DateOfBirth date,
Age INT,
ClassID INT,
SectionID INT,
PRIMARY KEY (ID)
)
INSERT INTO Students (Name, DateOfBirth, Age, ClassID, SectionID)
VALUES ('Adam','2003-06-16', 0, 6, 2)
INSERT INTO Students (Name, DateOfBirth, Age, ClassID, SectionID)
VALUES ('Botham','2001-03-22', 0, 8, 1)
INSERT INTO Students (Name, DateOfBirth, Age, ClassID, SectionID)
VALUES ('Hillton',Null, 0, 7, 2)
INSERT INTO Students (Name, DateOfBirth, Age, ClassID, SectionID)
VALUES ('Rasty','2004-12-02', 0, 5, 1)
INSERT INTO Students (Name, DateOfBirth, Age, ClassID, SectionID)
VALUES ('Holistar',Null, 0, 8, 1)