CRUD Statements  «Prev  Next»

Inserting Data from values in Different Table - Exercise

Create an INSERT statement using values from another Table

Objective:Practice creating an INSERT statement using values from another table.

Exercise Scoring

This exercise is worth a total of 10 points. You will receive up to 10 points for accurately creating the INSERT statement as described in the instructions.

Instructions

Consider the Department table that looks like this:

DepartmentID Description ManagerID
1Accounting302
2Human Relations342
3Information Systems501
4Legal106

Consider the DepartmentHistory table that looks like this (with no data in it):

DepartmentID ManagerID HistoryDate
   

Construct an INSERT statement that uses the DepartmentID value of 3 in the Department table and inserts into the DepartmentHistory table the DepartmentID, ManagerID, and HistoryDate columns. Use the GETDATE() function to insert the current date into the HistoryDate column.

Submitting the exercise

Type or paste your Transact-SQL statement into the text box below, then Submit to submit them and view a results page.