Você está na página 1de 3

Lab D: Using the Execute SQL Task

DTS Lab D: Using the Execute SQL Task


In this lab, you will use a stored procedure called time_dim_build to populate
the time_dim table. The time_dim_build stored procedure takes two input
parameters: a start date and an end date. When you execute the stored
procedure, it will load time_dim with date records between the start date and
end date.
If you have trouble completing the lab, please refer to the answer file at
C:\BITechnicalTraining\DTS\AnswerFiles\Lab D time_dim.dts.

Exercise 1
Loading Time_dim
Open up the Lab D starter package
.1 Right-click the Data Transformation Services folder, and then click Open
Package.
.2 In the Select File dialog box, type
C:\BITechnicalTraining\DTS\Packages\Lab D.dts in the File name box,
and then click Open.
.3 In the Select Package dialog box, double-click time_dim.

To create an Execute SQL Task with a parameterized query


.1 Click the Execute SQL Task in the Task toolbar.
.2 In the Execute SQL Task Properties dialog box, type execute
time_dim_build in the Description box.
.3 In the Existing connection list, click polaris.
.4 In the SQL statement box, type execute time_dim_build ?, ?
.5 Click Parse Query, and then click OK.

To create global variables for the input parameters


.1 Click Parameters to start the Parameter Mapping dialog box.
.2 Click the Input Parameters tab, and then click Create Global Variables.
.3 In the Global Variables dialog box, create two new global variables to map
to the query parameters.
.4 For the first global variable, type StartDate under the Name column.
.5 Click Date from the Type column.
.6 Type 01-JAN-1995 in the Value column.
.7 For the next global variable, type EndDate under the Name column.
.8 Click Date from the Type column.
.9 Type 01-JAN-2005 in the Value column, and then click OK.

APAC BI Technical Training

Lab D: Using the Execute SQL Task

To map the input parameters to global variables


.1 For Parameter 1 click StartDate from the Input Global Variables list.
.2 For Parameter 2 click EndDate from the Input Global Variables list.
.3 Verify that StartDate is mapped to Parameter 1 and the EndDate is
mapped to Parameter 2, and then click OK.
.4 Click OK to exit the Execute SQL Task Properties dialog box.

To define the package workflow


.1 Click the Delete Execute SQL Task, press the CTRL key, and click the
execute time_dim_build connection.
.2 Click the Workflow menu, and then click On Success.

To execute the DTS package


.1 Click the Execute play button on the toolbar, or click the Package menu,
and then click Execute.
.2 Click OK in the Package Execution Results dialog box.
.3 If any step failed, double-click the steps name to display the error message
for the step.
.4 Click Done.

To save the DTS package


.1 Click the Package menu, and then click Save As.
.2 Use the information in the following table to save the DTS package to your
local SQL Server. Accept the defaults for any options that are not listed,
click OK, and then close DTS Package Designer.
Parameter

Value

Package name

time_dim

Location

SQL Server

APAC BI Technical Training

Lab D: Using the Execute SQL Task

To verify package results


.1 Click Start, point to Programs, point to Microsoft SQL Server, and then
click Query Analyzer.
.2 In the Connect to SQL Server dialog box, click OK.
.3 Go to the database list in the toolbar and click polaris.
.4 Type the following query:
SELECT * FROM time_dim

.5 Click the Execute Query play button on the toolbar.


.6 Review data results. You should have 3653 records in the time dimension.
Verify a single record of data by using the following table.
Column name

Value

time_dim_key

<Values may vary>

full_date_app

1995-01-01 00:00:00.000

day_of_month

day_of_year

day_full_name

SUNDAY

week_number

month_full_name

JANUARY

month_number

quarter

calendar_year

1995

APAC BI Technical Training

Você também pode gostar