Lab 10 - Programming With Transact-SQL
Lab 10 - Programming With Transact-SQL
Overview
In this lab, you will use some basic Transact-SQL programming logic to work with data in the
AdventureWorksLT database.
Before starting this lab, you should view Module 10 – Programming with Transact-SQL in the Course
Querying with Transact-SQL. Then, if you have not already done so, follow the instructions in the Getting
Started document for this course to set up the lab environment.
If you find some of the challenges difficult, don’t worry – you can find suggested solutions for all of the
challenges in the Lab Solution folder for this module.
Tip: Review the documentation for variables and the IF…ELSE block in the Transact-SQL Language
Reference.
After the script has inserted the record, it should display the inserted SalesOrderID using the PRINT
command.
Tip: Review the documentation for WHILE in the Transact-SQL Language Reference.
Execute only if the average list price of a product in the ‘Bikes’ parent category is less than the
market average. Note that the product categories in the Bikes parent category can be
determined from the SalesLT.vGetAllCategories view.
Update all products that are in the ‘Bikes’ parent category, increasing the list price by 10%.
Determine the new average and maximum selling price for products that are in the ‘Bikes’
parent category.
If the new maximum price is greater than or equal to the maximum acceptable price, exit the
loop; otherwise continue.
Next Steps
Well done! You’ve completed the lab, and you’re ready to learn how to handle errors and implement
transactions in Transact-SQL by completing Module 11 – Error handling and Transactions in the Course
Querying with Transact-SQL.