1.4: Insert

For this challenge, you'll write a query that includes several different SQL statements to insert data into your table. This is sometimes referred to as "seeding" your table with data. Try experimenting with different syntax for the exercises in this challenge.

Write a query that inserts multiple products into the table. The resulting table should include the information listed below:

ProductID

ProductName

Price

ProductDescription

1

Clamp

12.4800

Workbench clamp

2

Clamp

12.4800

Workbench clamp

50

Flat Head Screwdriver

3.2500

Flat head

51

Screwdriver

3.2500

Flat head

52

Screwdriver

3.1700

Flat head

75

Tire Bar

NULL

Tool for changing tires

  • Write one statement that uses standard syntax to insert a product.

  • Write one statement that has a different order of columns for the insert. In other words, you should not enter the data so that "ProductID" is first, "ProductName" is second, "Price" is third, and "ProductDescription" is last.

  • Write one statement that skips using the column list, but keeps the values in order.

  • Write a statement that adds multiple items to the table at one time.

  • Write a statement that skips adding data in one of the nullable columns.

Follow the steps below to view your table in Visual Studio 1. Click on the white triangle next to "SQL_Library." This will expose additional folders - Tables, Views, Synonyms, Programmability, External Resources, Service Broker, Storage, and Security. 2. Click on the white triangle next to "Tables." Within the "Tables" folder, you will see 3 additional folders - System Tables, External Tables, and Views. Your new "Products" table should also be visible. It will be called "dbo.Products," as you can see in the screenshot below. 3. Right click on the table. A new menu will pop up. 4. Click on "View Data" in this menu. Your table, complete with your newly-inserted data, will appear in the main Visual Studio window.

If your table does not appear, try clicking the blue "Refresh" arrow (circled in yellow). Then, follow the steps above to navigate to your table again.

As in previous modules, your screen will not be identical to the screenshot above because you have different databases and tables in your server.

To see the solution for this challenge, click on 1.12 Solutions. Then, continue to Part 1.5: Update.

Last updated