$30
Before you start these exercises, you need to install SQL Server and the SQL Server Management Studio. The procedures for doing both of these tasks are provided in appendix A of the book.
In addition, you’ll need to get the Exercise Starts directory from your instructor. This directory contains some script files that you need to do these exercises.
Exercises
In these exercises, you’ll use SQL Server Management Studio to create the MyGuitarShop database, to review the tables in the MyGuitarShop database, and to enter SQL statements and run them against this database.
Create the database
1. Start SQL Server Management Studio and open a connection using either Windows or SQL Server authentication.
2. Open the script file named CreateMyGuitarShop.sql that’s in the Exercise Starts directory by clicking the Open File button in the toolbar and then using the resulting dialog box to locate and open the file.
3. Execute the entire script by clicking the Execute button in the SQL Editor toolbar or by pressing F5. When you do, the Messages tab indicates whether the script executed successfully.
Review the database
4. In the Object Explorer window, expand the node for the database named MyGuitarShop so you can see all of the database objects it contains. If it isn’t displayed in the Object Explorer window, you may need to click on the Refresh button to display it.
5. View the data for the Categories and Products tables.
6. Navigate through the database objects and view the column definitions for at least the Categories and Products tables.
Enter and run SQL statements
7. Select the MyGuitarShop database from the Available Databases dropdown menu (Crtl + U) to choose it as the default database.
8. Open a new Query Editor window. Then, enter and run this SQL statement:
SELECT ProductName FROM Products
9. Delete the e at the end of ProductName and run the statement again. Note the error number and the description of the error.
10. Open another Query Editor window by clicking the New Query button. Then, enter and run this statement:
SELECT COUNT(*) AS NumberOfProducts FROM Products
Open and run scripts
11. Open the script named ProductDetails.sql that’s in the Exercise Starts directory. Note that this script contains just one SQL statement. Then, run the statement.
12. Open the script named ProductSummary.sql that’s in the Exercise Starts directory. Note that this opens another Query Editor window.
13. Open the script named ProductStatements.sql that’s in the Exercise Starts directory. Notice that this script contains two SQL statements that end with semicolons.
14. Press the F5 key or click the Execute button to run both of the statements in this script. Note that this displays the results in two Results tabs. Make sure to view the results of both SELECT statements.
15. Exit from SQL Server Management Studio.