Module 1 Lab: Creating A Database
Module 1 Lab: Creating A Database
1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click
SQL Server Management Studio.
2. In the Connect to Server dialog box, specify the values in the following table, and then click
Connect.
Property Value
Server type Database Engine
Server name MIAMI
Authentication Windows Authentication
5. On the Project menu, click New Query. Connect to MIAMI by using Windows
authentication when prompted.
6. If Solution Explorer is not visible, click Solution Explorer on the View menu.
7. In Solution Explorer, right-click SQLQuery1.sql, and then click Rename. Rename the file to
CreateAW_IT_Assets.sql.
Creating the new database with appropriate options and filegroups
You must perform the following steps to create the new database with appropriate
options and filegroups:
1. If Object Explorer is not visible, click Object Explorer on the View menu.
2. In Object Explorer, right-click Databases, and then click New Database.
3. In the New Database dialog box, type AW_IT_Assets as the Database name.
4. For the first database file, modify the details to match those in the following table.
Property Value
Logical Name AW_IT_Assets_Data1
File Type Data
Filegroup PRIMARY
Initial Size (MB) 20
5. In the Autogrowth column of the AW_IT_Assets_Data1 entry, click the ellipsis button (…).
6. In the Change Autogrowth for AW_IT_Assets_Data1 dialog box, clear the Enable
Autogrowth check box, and then click OK.
7. Click Add to create a new data file.
8. For the new database file, enter the details in the following table.
Property Value
Logical Name AW_IT_Assets_Data2
File Type Data
Initial Size (MB) 20
9. In the Autogrowth column of the AW_IT_Assets_Data2 entry, click the ellipsis button (…).
10. In the Change Autogrowth for AW_IT_Assets_Data2 dialog box, clear the Enable
Autogrowth check box, and then click OK.
11. In the Filegroup column for the AW_IT_Assets_Data2 file, click <new filegroup> in the
drop-down list.
12. In the New Filegroup for AW_IT_Assets dialog box, enter the details in the following table,
and then click OK.
Property Value
Name Secondary
Options - Default Select the check box
13. Change the Initial Size setting for the AW_IT_Assets_log entry to 5.
14. In the Autogrowth column of the AW_IT_Assets_log entry, click the ellipsis button (…).
15. In the Change Autogrowth for AW_IT_Assets_log dialog box, clear the Enable
Autogrowth check box, and then click OK.
16. In the New Database dialog box, click the Script drop-down arrow on the toolbar, and then
click Script Action to Clipboard.
17. Click OK to create the new database.
18. Click in the CreateAW_IT_Assets.sql window to ensure it is active, and on the Edit menu,
click Paste.
19. On the File menu, click Save All.
20. Do not close SQL Server Management Studio; you will use it in the next exercise.
Exercise 2: Creating Schemas
USE AW_IT_Assets
SELECT * FROM Asset
GO
An error message is displayed within the command prompt window because the dbo schema does
not contain the Asset table.
6. Enter the following code.
USE AW_IT_Assets
SELECT * FROM TechSupport.Asset
GO
Three records are displayed within the command prompt window because the statement includes
the schema.
7. Do not close the command prompt window.
USE AW_IT_Assets
SELECT * FROM Asset
GO
Three records are displayed within the command prompt window because the default schema for
MIAMI\Katie is now TechSupport.
10. Type Exit to close the sqlcmd connection and close the command prompt window.
11. Keep SQL Server Management Studio open; you will use it in the next exercise.
Exercise 3: Creating a Database Snapshot
1. In SQL Server Management Studio, on the Project menu, click New Query. Connect to
MIAMI by using Windows authentication when prompted.
2. In Solution Explorer, right-click SQLQuery1.sql, and then click Rename. Rename the file to
CreateAW_IT_Snapshot.sql.
3. In the new, blank query window, type the following Transact-SQL code.
SELECT *
FROM AW_IT_Assets.TechSupport.Asset
SELECT *
FROM AW_IT_Assets_Snapshot1.TechSupport.Asset
12. Click the Execute button on the toolbar, and view the results. Notice that the first result set
contains four records and the second contains only three records, as expected.
13. Return to Windows Explorer.
14. Right-click AWIT2.ss, and then click Properties. Notice that the new Size on disk value is
different from the previous value. Click OK, and then close Windows Explorer.
15. Close SQL Server Management Studio.