Professional Documents
Culture Documents
1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and 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. When prompted, use Windows authentication to
connect to MIAMI.
6. If Solution Explorer is not visible, click Solution Explorer on the View menu.
Creating the ShortDescription and CashValue data types
You must use the following procedure to create the ShortDescription and CashValue
data types:
1. In Solution Explorer, right-click SQLQuery1.sql, and then click Rename. Rename the file to
CreateDataTypes.sql.
2. In the query window, type the following Transact-SQL code to create the ShortDescription
data type.
USE AdventureWorks
CREATE TYPE dbo.ShortDescription
FROM nvarchar(100)
NULL
3. Add the following Transact-SQL code to create the CashValue data type.
1. On the Project menu, click New Query. When prompted, use Windows authentication to
connect to MIAMI.
2. If Solution Explorer is not visible, click Solution Explorer on the View menu.
3. In Solution Explorer, right-click SQLQuery1.sql, and then click Rename. Rename the file to
CreateTables.sql.
1. On the Project menu, click New Query. When prompted, use Windows authentication to
connect to MIAMI.
2. If Solution Explorer is not visible, click Solution Explorer on the View menu.
3. In Solution Explorer, right-click SQLQuery1.sql, and then click Rename. Rename the file to
CreatePartitionedTable.sql.
4. In the query window, type the following Transact-SQL code to create the pf_ReturnDate
partition function.
USE AdventureWorks
CREATE PARTITION FUNCTION pf_ReturnDate (datetime)
AS RANGE RIGHT
FOR VALUES ('01/01/2005', '01/01/2006')
1. Add the following Transact-SQL code to create the ps_ReturnDate partition scheme.
2. Select the CREATE PARTITION SCHEME statement, and then click the Execute button on
the toolbar to execute it.
Creating a partitioned table
You must perform the following procedure to create a partitioned table:
2. Select the CREATE TABLE statement, and then click the Execute button on the toolbar to
execute it.
3. On the File menu, click Save All.
1. On the Project menu, click Add Existing Item, and then add the
D:\Labfiles\Starter\InsertReturnsArchive.sql script file. When prompted, use Windows
authentication to connect to MIAMI.
2. Click the Execute button on the toolbar (or press F5) to execute the query. This inserts some
test data into the ReturnsArchive table.
1. Under the existing code, add the following Transact-SQL statement to retrieve partition usage
information.
SELECT ReturnID, ReturnDate, $Partition.pf_ReturnDate(ReturnDate)
PartitionNo
FROM Sales.ReturnsArchive
2. Select the SELECT statement, and then click the Execute button on the toolbar to execute it.
When all rows have been returned, scroll through the results and verify that the data is spread
across three partitions.
3. On the File menu, click Save All.
4. Close SQL Server Management Studio.