Inserting and updating a table
A very important task when working with tables is inserting and updating the values in a database. The syntax for both operations is shown below.
Insert value1
and value2
into the Employee
table:
INSERT INTO Employee
VALUES (value1, value2);
Update field1
from table Employee
with value1
for the ID=1
:
UPDATE Employee
SET field1 = value1
WHERE ID = 1;
Your task is to insert two new values into the Person
table and to update the entries of the table.
This exercise is part of the course
Hierarchical and Recursive Queries in SQL Server
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Insert the records for the person with ID=1
___ INTO ___
____ (1,'Andrew','Anderson','Union Ave 10','New York','1986-12-30');
-- Insert the records for the person with ID=2
INSERT INTO Person
VALUES (___,___,___,___,___,___);
SELECT *
FROM Person;