SQL Server 2000的数据转换服务(下)
数据泵:转换数据
DTS 数据泵是一个 DTS对象,它驱动数据的导入、导出和转换操作。
在执行数据转换、数据驱动查询和并行数据泵任务期间将使用数据泵。执
行这些任务的过程是:在源和目标连接上创建行集合,然后创建数据泵实
例在源和目标间移动这些行。在复制每一行时,将进行转换操作。
下图中,在第二个步骤中,转换数据任务在 Access DB任务和 SQL
Production DB任务之间进行。转换数据任务用连接间的灰色箭头表示。
图 7. 示例:转换数据任务
要定义从源连接收集的数据,可以生成一个转换任务的查询。DTS 支
持参数化查询,参数化查询允许在执行查询时定义查询值。
可以将查询键入任务的“属性”对话框,也可以使用数据转换服务查
询设计器,它是一个用图形化方式生成 DTS任务查询的工具。下图中,使
用查询设计器来生成一个查询,该查询联接 pubs 数据库中的三个表。
图 8. 数据转换服务查询设计器界面
在转换任务中,还可以定义要对数据进行的更改。下表说明 DTS提供
的内置转换。
转换 说明
复制列 用于在不应用任何转换的情况下将数据直接从源列复制到目标列。
ActiveX 脚本 用于生成自定义转换。请注意,因为转换将逐行进行,ActiveX 脚本可能影响 DTS 软件包的执行速度。
DateTime 字符串 用于将源列中的日期或时间转换为目标列中的另一种格式。
小写字符串 用于将源列转换为小写字符形式,如需要,将其转换为目标数据类型。
大写字符串 用于将源列转换为全大写字符形式,如需要,将其转换为目标数据类型。
中间字符串 用于从源列抽取子字符串,对其进行转换后将结果复制到目标列。
修剪字符串 用于删除源列中字符串的前导空格、尾随空格和嵌入空格,然后将结果复制到目标列。
读取文件 用于打开文件内容(文件名称在源列中指定),然后将内容复制到目标列。
写入文件 用于将源列(数据列)的内容复制到一个文件中,该文件的路径由第二个源列(文件名列)指定。
还可以用编程方式创建自己的自定义转换。生成自定义转换最快速的
方式是使用活动模板库(ATL )自定义转换模板,SQL Server 2000 DTS
样本程序中包括该模板。
数据泵错误记录
SQL Server 2000 中提供了一种记录转换错误的新方法。可以定义三
种异常情况记录文件来记录软件包执行期间的情况:错误文本文件、源错
误行文件和目标错误行文件。
●一般错误信息将写入错误文本文件中。
●如果转换失败,源行出现错误,该行将写入源错误行文件。
●如果插入失败,目标行出现错误,该行将写入目标错误行文件。
在转换数据的任务中将定义异常情况日志文件。每个转换任务都有自
己的日志文件。
数据泵阶段
默认情况下,数据泵有一个阶段,即行转换。该阶段是在未选择阶段
的情况下,在转换数据任务、数据驱动查询任务和并行数据泵任务中映射
列一级的转换时配置的。
多个数据泵阶段是 SQL Server 2000中新增的。通过在 SQL Server
企业管理器中选择多阶段数据泵选项,在数据泵操作过程中的不同阶段都
可以访问数据泵并添加功能。
将数据行从源复制到目标时,数据泵将按照下图中所显示的基本进程
进行操作。
图 9. 数据泵进程
数据泵处理完最后一行数据后,任务结束,数据泵操作终止。
如果高级用户要向软件包添加功能,以便软件包能支持任何数据泵阶
段,可以执行以下操作:
●为每个要自定义的数据泵阶段编写一个 ActiveX 脚本阶段函数。如果
使用 ActiveX 脚本函数来自定义数据泵阶段,不需要该软件包以外的
其它任何代码。
●使用 Microsoft Visual C++? 创建 COM 对象来自定义所选的数据泵阶
段。在该软件包之外开发此程序,在执行转换过程中每个所选的阶段时
将调用该程序。访问数据泵阶段的 ActiveX 脚本方法中每个所选阶段
都使用不同的函数和输入点;而这种方法则不同,它在数据泵任务执行
期间提供一个单一输入点,该输入点将被多个数据泵阶段调用。
保存 DTS 软件包的选项
以下选项可用于保存 DTS 软件包:
●Microsoft SQL Server
如果要将软件包存储到网络中 SQL Server 的任意实例上,该选项将
DTS 软件包保存到 Microsoft SQL Server ,保留一个便于使用的这些软
件包的清单,并在软件包开发进程中添加和删除软件包版本。
●SQL Server 2000 元数据服务
如果准备跟踪软件包版本、元数据和数据系列信息,该选项将 DTS软
件包保存到元数据服务。
●结构化存储文件
如希望在网络间复制、移动和发送软件包而不必将其存储在Microsoft
SQL Server数据库中,该选项将 DTS软件包保存到结构化存储文件。
●Microsoft Visual Basic
如果要将 DTS软件包合并到 Visual Basic 程序中或将其用作 DTS应
用程序开发的原型,该选项将通过 DTS设计器或 DTS导入/ 导出向导所创
建的 DTS软件包保存到 Microsoft Visual Basic 文件。
DTS 作为应用程序开发平台
DTS 设计器为数据移动任务提供了多种解决方案。因为提供通过编程
方式访问 DTS对象模型的功能,DTS 扩展了可用的解决方案的数目。使用
Microsoft Visual Basic、Microsoft Visual C++或任何其它支持 COM的
应用程序开发系统,都可以使用图形化工具所不支持的功能开发出适合于
您的环境的自定义 DTS解决方案。
DTS 为开发人员提供多种不同方式的支持:
●生成软件包
无需使用 DTS设计器或 DTS导入/ 导出向导,您就可以开发极为复杂
的软件包,并可访问对象模型中的全套功能。
●扩展软件包
通过构建自定义任务和转换,可以添加一些适用于您的业务并可在 DTS
内重复使用的新功能。
●执行程序包
并非一定要使用所提供的工具来执行 DTS软件包,可以用编程方式执
行DTS软件包并通过 COM事件显示进度,并允许构建嵌入的或自定义的DTS
执行环境。
样本DTS程序有助于了解DTS编程的入门知识。该样本可与SQL Server
2000一起安装。
如果开发 DTS应用程序,可以重新分发 DTS文件。有关详细信息,请
参阅 SQL Server 2000光盘上的 Redist.txt。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Oracle and DB2 are two commonly used relational database management systems, each of which has its own unique SQL syntax and characteristics. This article will compare and differ between the SQL syntax of Oracle and DB2, and provide specific code examples. Database connection In Oracle, use the following statement to connect to the database: CONNECTusername/password@database. In DB2, the statement to connect to the database is as follows: CONNECTTOdataba

"Usage of Division Operation in OracleSQL" In OracleSQL, division operation is one of the common mathematical operations. During data query and processing, division operations can help us calculate the ratio between fields or derive the logical relationship between specific values. This article will introduce the usage of division operation in OracleSQL and provide specific code examples. 1. Two ways of division operations in OracleSQL In OracleSQL, division operations can be performed in two different ways.

Interpretation of MyBatis dynamic SQL tags: Detailed explanation of Set tag usage MyBatis is an excellent persistence layer framework. It provides a wealth of dynamic SQL tags and can flexibly construct database operation statements. Among them, the Set tag is used to generate the SET clause in the UPDATE statement, which is very commonly used in update operations. This article will explain in detail the usage of the Set tag in MyBatis and demonstrate its functionality through specific code examples. What is Set tag Set tag is used in MyBati

What is Identity in SQL? Specific code examples are needed. In SQL, Identity is a special data type used to generate auto-incrementing numbers. It is often used to uniquely identify each row of data in a table. The Identity column is often used in conjunction with the primary key column to ensure that each record has a unique identifier. This article will detail how to use Identity and some practical code examples. The basic way to use Identity is to use Identit when creating a table.

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

Understand the role and usage of LinuxDTS In the development of embedded Linux systems, Device Tree (DeviceTree, DTS for short) is a data structure that describes hardware devices and their connection relationships and attributes in the system. The device tree enables the Linux kernel to run flexibly on different hardware platforms without modifying the kernel. In this article, the function and usage of LinuxDTS will be introduced, and specific code examples will be provided to help readers better understand. 1. The role of device tree device tree

Solution: 1. Check whether the logged-in user has sufficient permissions to access or operate the database, and ensure that the user has the correct permissions; 2. Check whether the account of the SQL Server service has permission to access the specified file or folder, and ensure that the account Have sufficient permissions to read and write the file or folder; 3. Check whether the specified database file has been opened or locked by other processes, try to close or release the file, and rerun the query; 4. Try as administrator Run Management Studio as etc.
