Data warehouses centralize data to improve corporate decision making. However, the source data is often in a large variety of formats stored on a number of different systems. By using DTS, you can import, export, and transform data among multiple homogeneous or heterogeneous sources and destinations using an OLE DB-based architecture. This lesson introduces you to DTS and describes how to create a DTS package using the DTS Import and DTS Export wizards.
After this lesson, you will be able to:
- Describe the purpose of DTS packages
- Create a DTS package with the DTS Import and DTS Export wizards
Estimated lesson time: 60 minutes
DTS is able to import, export, and transform data between SQL Server and any OLE DB, Open Database Connectivity (ODBC), or text file format. When you use DTS, you can
DTS can be used with any OLE DB data source and destination; you are not required to use SQL Server 7 for either source or destination. This makes DTS a general-purpose data transfer and transformation tool with a wide range of applications, including data warehousing. If you use DTS in this way, you are required to have a normal SQL Server license.
NOTE
DTS moves table schema and data between heterogeneous data sources. Triggers, stored procedures, rules, defaults, constraints, and user-defined data types can be transferred only if the source and destination are both SQL Server 7.0
The process of transferring data is an integral part of all DBMSs. DTS provides an extensible COM-based architecture that allows customers, independent software vendors (ISVs), and consultants to create new OLE DB data sources and destinations, tasks, and transformations.
With DTS, users create and execute a DTS package, which completely describes all of the work that is performed as part of the transfer and transformation process.
A DTS package defines one or more data transformation steps. Steps are executed in a coordinated sequence, which you can control. Each step can perform a different type of operation. For example, step 1 might copy and transform data from an OLE DB source to an OLE DB destination by using the DTS data pump; step 2 might execute a script; and step 3 might load and execute an external program (.EXE) or even a batch file (.CMD or .BAT). Figure 6.2 illustrates such a DTS package.
Figure 6.2 An example of a DTS package
DTS packages are self-contained and can be executed from SQL Server Enterprise Manager or by using the dtsrun utility. DTS packages can be stored in the msdb database in SQL Server, linked to the Microsoft Repository, or saved as COM-structured storage files. These options and their implications are described in Chapter 8, "Advanced DTS."
When you use DTS, the data source and destination can be heterogeneous. Using SQL Server as a data source or destination is not required. DTS may simply be the mechanism that transfers data between two data sources.
DTS uses OLE DB providers to import, export, and transform data. Using OLE DB allows access to a variety of data source and destination types such as databases, spreadsheets, text files, and so on.
Using DTS steps, it is also possible to create packages that do such things as performing high-speed nonlogged inserts (using bcp or BULK INSERT), transforming and publishing data as HTML, or exporting data to pivot tables in Microsoft Excel.
The DTS data pump is an OLE DB service provider that allows the infrastructure to import, export, and transform data between heterogeneous data stores. It is a high-speed, in-process COM server that moves and transforms OLE DB rowsets. The DTS Data Pump uses OLE DB because OLE DB provides access to the broadest possible range of relational and nonrelational datastores.
The DTS data pump provides the extensible COM-based architecture that allows complex data validations and transformations as the data moves from the source to the destination. The data pump exposes the source and destination OLE DB rowsets to scripting languages, such as VBScript, and Microsoft JScript, in a DTS package. This ability allows the expression of complex procedural logic as simple, reusable ActiveX scripts. Scripts can validate, convert, or transform column values as they move from the source through the data pump to the destination.
DTS tools include the DTS Import wizard, the DTS Export wizard, DTS Designer, the dtswiz and dtsrun command-prompt utilities, and the DTS node in the SQL Server Enterprise Manager console tree.
The DTS Import and DTS Export wizards offer many ways to customize or simplify the method in which data is copied from source to destination. With DTS wizards, you can
NOTE
When copying a table, the DTS wizards, by default, do not copy indexes, triggers, or constraints. If you want to have the package create the table, you can manually edit the Transact-SQL that is used to create the table and add the statements needed to create indexes, triggers, or constraints.
You can start the DTS Import wizard and the DTS Export wizard from SQL Server Enterprise Manager, from the Microsoft SQL Server 7 program group on the Start Menu, or by using the dtswiz command prompt utility.
NOTE
The DTS Import wizard and the DTS Export wizard are the same utility. You can move data into or out of SQL Server or any other OLE DB data source using either wizard. The text in the title bar of the utility changes depending on which wizard you select.
In this exercise, you will import summary data into a new table using the DTS Import wizard.
In the following steps, if an option is not specified, accept the default.
SELECT ProductName, SUM(o.UnitPrice * Quantity) AS Total FROM [Order Details] o INNER JOIN Products p ON o.ProductID = p.ProductID GROUP BY ProductName |
If you don t want to type the query, you can click Browse and open C:\SQLDW\Exercise\Ch06\Query.sql.
SELECT * FROM Northwind..ProductTotals |
In this exercise, you will export data using the DTS Export wizard and save the DTS package. The DTS package will copy a list of South American customers into a delimited text file.
In the following steps, if an option is not specified, accept the default.
In this exercise, you will review the job schedule that was created to execute your DTS package.
DTS Designer is a graphical DTS package editor. The work surface includes a toolbar and an extensible tool palette that you can use to add package objects and specify workflow.
When you create a new DTS package from the console tree, the DTS Designer work surface opens in a new Microsoft Management Console (MMC) window. Two tool palettes contain icons for transformation tasks and data connections.
Experienced users can use DTS Designer to integrate, consolidate, and transform data from multiple heterogeneous sources, using complex workflows to simplify the process of building a data warehouse. Chapter 8, "Advanced DTS," describes data transformations.
DTS is a general-purpose data transfer and transformation tool with a wide range of applications. It provides the ability to copy table schema and data between DBMSs, create custom transformation objects, access applications using third-party OLE DB providers, and build data warehouses and data marts in SQL Server. DTS can be used with any OLE DB data source and destination; you are not required to use SQL Server 7 for either source or destination.
DTS tools include the DTS Import wizard, the DTS Export wizard, DTS Designer, the dtswiz and dtsrun command-prompt utilities, and the Data Transformation Services node in the SQL Server Enterprise Manager console tree.