Question: 1. Create two temporary tables. The first table should have and ID column and a column called State. The second table should have an ID

1. Create two temporary tables. The first table should have and ID column and a column called State. The second table should have an ID column, a StateID column, and a column called City. Use T-SQL statements for all of the work.

2. Populate the tables with at least 10 rows in each table. Each of the data elements you are modeling should have information in both tables. pick ten states and then at least ten cities that exist in one of the states.

3. Create a third temporary table with the results of both tables. That is, create a table that would hold an ID, a city name and a state name. Create an insert statement to populate the table using the first two temporary tables.

4. Run an update statement to change swap out two states. That is, if you picked California and had rows (1, Los Angeles,California) and (2, Madison, Wisconsin), after your update, wed have Los Angeles, Wisconsin and Madison, California.

5. Following an example where JP moved from California to Wisconsin, create a fourth temporary table with the changes that you wish to make and construct an UPDATE statement using a join to that third table. For example, your table could have (San Francisco, Montana) and you want to use an update, joining to that table, to move San Francisco to Montana.

6. Finally, Use an ALTER TABLE statement to add one new column of data type datetime to one of your tables. Include a default of 1/1/18. Write an INSERT statement to add a row without referring directly to the new column, and a second insert placing 6/1/18 in the new column.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!