1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Microsoft SQL Server 2000 Data Transformation Services- P2 docx

50 439 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 913,1 KB

Nội dung

The performance issue can be confusing because some of the DTS tasks are executed locally where the package is executing, while others are executed remotely on the database server. Here are some of the tasks that are executed in the local context: •All the transformation tasks—The Transform Data, Data Driven Query, and Parallel Data Pump tasks. The performance of these tasks can be significantly degraded when they are executed on one machine and the data they are processing is on another. • The Execute Process task. • The Execute Package task. The following list contains tasks that are executed on the database server and not on the machine where the package is executed. If you are only using these tasks, you will not have performance problems caused by execution context: • The Bulk Insert task • The Copy SQL Server Objects task • The Transfer Databases task • The Execute SQL task Here are some of your options for executing a DTS package on a database server, instead of on your workstation, when you do not have direct access to the server: •Use remote management software and execute the package using DTSRun. • Schedule the package on the server. Make sure the SQL Server Agent has all the permis- sions needed to carry out the package’s operation. •Execute the package on the server using the OLE Automation system stored procedures or by using xp_cmdshell with DTSRun. You could do either of these from an Execute SQL task within another DTS package. Chapter 26 has more information on the solution using the OLE Automation system stored procedures. Getting Started with DTS P ART I 26 Many DTS developers have run into the security problem when they schedule their DTS packages. You can log on to your computer with the same user ID as the SQL Agent is using. This will allow you to test your DTS packages in the security context that will be used when the package is executed by the SQL Agent. NOTE 03 0672320118 CH01 11/13/00 5:04 PM Page 26 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Using the DTS Object Model for Programmatic Control DTS is implemented with the Component Object Model (COM). You can manipulate DTS packages and their components through the appropriate collections, objects, properties, and methods that are exposed in the DTS object model. A Quick Look at DTS C HAPTER 1 1 A Q UICK LOOK AT DTS 27 If you’re a programmer, you’ll be interested in this section. If you’re not a programmer (and I know a lot of excellent database developers who aren’t), you’ll still find this material valuable. You can access the properties of DTS objects through two new features—the Dynamic Properties task and Disconnected Edit. These tools allow you to manipulate object properties directly, without pro- gramming. Throughout the book, I will attempt to connect what you can do in the DTS Designer interface with what you can do with the DTS object model, so that you can use code, the Dynamic Properties task, and Disconnected Edit to extend your control over DTS. NOTE The DTS object model is the theme of Chapter 30. Almost all of the chapters in this book refer to the various structures within the object model. The DTS Object Model The Package object is at the top of the DTS object hierarchy. All the objects that do the work of a DTS package stem from this object. The Package object contains four collections of objects: • Connections—Defined links to particular sources of data. • Tasks—The actions that take place in a package. • Steps—An object associated with a task that controls how the task fits into the workflow of the package as a whole. • Global Variables—Variables that allow for sharing of information between the various tasks. Values of global variables can also be sent into a package. Each task has an associated object called a custom task that contains the properties specific to that particular kind of DTS task. 03 0672320118 CH01 11/13/00 5:04 PM Page 27 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. There are several other DTS objects that do not fit under the Package object. These other objects primarily provide information: • Application—System properties and information. • TransformationInfo—DTS transformations that are registered. • ScriptingLanguageInfo—Scripting languages that are registered. • SavedPackageInfo—Packages that are stored as files. Using the DTS Object Model with the Dynamic Properties Task You can use the new Dynamic Properties task to change the properties of DTS objects while a package is being executed. You create the workflow for this task so that the values are updated at the correct point in the package execution, as shown in Figure 1.13. Getting Started with DTS P ART I 28 FIGURE 1.13 The Dynamic Properties task allows you to change properties of an object as a package is executing. When you are selecting a new property for modification, a tree structure is displayed (see Figure 1.14). This tree shows all the objects that have been defined for that particular package. You can select any of them and specify the new value you want assigned to a particular prop- erty. Besides setting the value to a constant, you can set the value to a global variable, retrieve a value in a query, load the value from a file, or look up the value in an INI file. 03 0672320118 CH01 11/13/00 5:04 PM Page 28 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. FIGURE 1.14 There are many properties of the DTS objects that can be set with the Dynamic Properties task. The Dynamic Properties task has one very significant limitation—you cannot add any new objects with this task. If you want to dynamically create a new connection, task, lookup, trans- formation, or any other object while a package is executing, you have to create it using code. Using the DTS Object Model with Disconnected Edit Disconnected Edit is a tool that allows you to directly edit a number of properties of DTS objects. You can get to Disconnected Edit by right-clicking on the Design Sheet and choosing it from the menu, or by selecting Disconnected Edit from the Package menu. When you choose Disconnected Edit, the Edit All Package Properties dialog opens, as shown in Figure 1.15. The interface for Disconnected Edit looks very similar to the interface for Dynamic Properties Task, but there are three significant differences: • The Dynamic Properties task is a tool for making property changes while a package is executing, while Disconnected Edit is a tool for modifying properties while designing a package. •You can modify many more properties with Disconnected Edit than you can with the Dynamic Properties task. • When you use Disconnected Edit, you always set the properties to a value, whereas the Dynamic Properties task allows you to set property values in a variety of ways. A Quick Look at DTS C HAPTER 1 1 A Q UICK LOOK AT DTS 29 03 0672320118 CH01 11/13/00 5:04 PM Page 29 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. FIGURE 1.15 You can edit the greatest number of properties when you use Disconnected Edit. Getting Started with DTS P ART I 30 Disconnected Edit and, to a lesser extent, the Dynamic Properties task allow you to change properties of DTS objects to invalid or inappropriate values. When you are setting values of object properties in the Package Designer, the Designer checks the data structure in the connection to see if those values are appro- priate. The fundamental purpose of Disconnected Edit is to allow you to set values for data sources in situations where you are not connected to them. I believe that the usefulness of Disconnected Edit goes far beyond its basic purpose. However, whenever you change something in Disconnected Edit, you are responsible for ensuring that the change is appropriate. The Package Designer does very little checking beyond assuring that you have used the correct datatype for the value. Using Disconnected Edit is somewhat analogous to using the Windows Registry. When you make a change in the Registry, the system doesn’t check if that change is appropriate for the programs that are being affected. You have to know what you’re doing. You can change properties with Disconnected Edit in a way that will confuse your package. If you change the ID of a Connection object, for example, you will break the link between that Connection and all the tasks that use it. CAUTION 03 0672320118 CH01 11/13/00 5:04 PM Page 30 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Programming DTS with VBScript You can use the DTS object model in the ActiveX scripts inside your DTS packages to create new objects and modify their properties. The examples in this book show how to do this with VBScript, but you can also use the other scripting languages. Programming with the DTS object model in ActiveX scripts is useful in at least three ways: •You can dynamically modify the package as it is executing. You can modify properties, and you can also create new objects such as connections, tasks, and transformations. •You can run scripts in ActiveX Script tasks as part of the design process to simplify the process of making changes throughout the package. •You can query the structure of the package for the purpose of reporting or documenting the package design. The use of the DTS object model in VBScript is discussed in Chapter 16, “Writing Scripts for an ActiveX Script Task,” and Chapter 7, “Writing ActiveX Scripts for a Transform Data Task.” Chapter 16 explains how to change code from VB to VBScript and back again. Programming DTS with Visual Basic DTS in SQL Server 2000 is more integrated with Visual Basic than DTS in SQL Server 7.0. You now have the option of saving a package to VB. You can do the following with Visual Basic in DTS: •Create new packages. •Save packages to VB for editing. •Execute packages and handle errors that are generated from them. A Quick Look at DTS C HAPTER 1 1 A Q UICK LOOK AT DTS 31 Another issue in using Disconnected Edit is that you can unintentionally overwrite some of your changes in your ongoing development. In the Transform Data task, for example, there is a property called ExceptionFileOptions that holds a value that is the sum of a number of possible bit flags. Some of the flags can be set in the Transform Data Task Properties dialog. You can add additional flags using Disconnected Edit, but if you then open the tab of the dialog where the value is set, the values you have added in Disconnected Edit will be overwritten. I encourage you to become familiar with the power of Disconnected Edit, but I also encourage you to be careful in using that power. It’s always better to use the Package Designer interface if it will allow you to do what you want to accomplish. 03 0672320118 CH01 11/13/00 5:04 PM Page 31 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. • If you execute a package from VB, you can build an interface that allows a user to modify the package before it is executed. •Create new DTS custom tasks. These topics are discussed in Chapter 26 and Chapter 31, “Creating a Custom Task in VB.” Programming DTS with VC++ Almost everything you can do with a DTS package using VB, you can also do with VC++. The major difference, of course, is that you can’t save a package to VC++ as you do for VB. The one additional thing you can do with VC++ that you can’t do with Visual Basic is create custom transformations. You can greatly increase the speed of a transformation by moving it from an ActiveX script into a custom transformation. Programming custom transformations with VC++ is the topic of Chapter 32. DTS Templates SQL Server 2000 has added DTS templates to speed the development of DTS packages. If you are creating a number of packages that are similar, you can create the package once as a tem- plate and then use that template as the basis for all your individual packages. Using Templates A DTS template is always saved as a file with a .dtt extension. You can open a template in one of two ways: •Right-click on the Data Transformation Services node in the Enterprise Manager and select All Tasks and Open Template from the popup menu. •Highlight the Data Transformation Services node and select All Tasks and Open Template from the Action menu. The template has a set of tasks and precedence constraints that have already been created. You use these objects as the starting point for a new DTS package. You cannot modify a template. The first time you save the new package you will be asked to enter storage information. Creating Templates You create a DTS template in the same way you create a DTS package, except for these things: •Use Disconnected Edit to fill in object properties that will be changed when the template is used. This is especially important for connection properties, because the connections Getting Started with DTS P ART I 32 03 0672320118 CH01 11/13/00 5:04 PM Page 32 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. will not be able to be validated at the time the template is created. You can use a phrase that indicates the need to change the value, such as “Enter Source Server Name Here”. • Add annotations to explain to the template users where they have to fill in property values. • When you have finished your template, save it as a Structure Storage File. As you’re sav- ing it, change the extension from .dtt to .dts, so that SQL Server will recognize it as a template file. If you want to change an existing template you have to open it up, make the changes, and save it with a different file name. Using Wizards for Rapid Application Development SQL Server 2000 provides two wizards that automate the process of creating a DTS package. One of these wizards, the Import/Export Wizard, is almost unchanged from SQL Server 7.0. The other one, the Copy Database Wizard, is new. Both wizards create DTS packages. You can modify these packages with the DTS Designer. The two DTS Wizards are the topic of Chapter 25. Copy Database Wizard The Copy Database Wizard is used for the following tasks: •Moving a SQL Server database from one server to another. •Moving meta data that’s critical to the operation of a database between servers. • Upgrading a SQL Server database to SQL Server 2000. It’s important to be able to transfer the meta data along with the databases. Databases depend on certain types of information that is stored by SQL Server in the master and msdb databases. The kinds of meta data that can be moved with this wizard are •User-defined error messages. • Shared stored procedures from the master database. • Logins. • Scheduled jobs. You can open the Copy Database Wizard in the Enterprise Manager by highlighting the SQL Server node and selecting Wizards from the Tools menu. The Copy Database Wizard is listed under the Management node in the Select Wizard dialog. The opening screen of the wizard is shown in Figure 1.16. A Quick Look at DTS C HAPTER 1 1 A Q UICK LOOK AT DTS 33 03 0672320118 CH01 11/13/00 5:04 PM Page 33 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. FIGURE 1.16 The new Copy Database Wizard allows you to copy or move one or more SQL Server databases to SQL Server 8.0. You cannot use one of the sample databases to try the Copy Database Wizard because you are not allowed to copy a database to a server that already has a database with that name. If you want to try using the Wizard, I suggest that you create a new database and choose that database for copying: 1. Create a new database on the SQL Server you are going to use as the source. 2. Open the Copy Database Wizard. 3. Select the source server. 4. Select the destination server. 5. Select Move or Copy for the database you have created. 6. You should not have to change the database file location. 7. You can leave the default choices for the related objects. 8. Select the Run Once option and schedule the package to run a couple of years from now. 9. Open the package in the DTS Designer to see what the wizard has created. Run the pack- age and view the results. DTS Import/Export Wizard You can use the DTS Import/Export Wizard to rapidly create a DTS package that moves data. You can use it to do the following: •Create connections. •Transfer SQL Server Object tasks. •Transform data tasks. •Execute SQL tasks to drop and create tables, if necessary. Getting Started with DTS P ART I 34 03 0672320118 CH01 11/13/00 5:04 PM Page 34 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. You can open the DTS Import/Export Wizard in a number of ways, including opening it in the Enterprise Manager by highlighting the SQL Server node and selecting Wizards from the Tools menu. The DTS Export Wizard and the DTS Import Wizard are listed under the Data Transformation Services node. These two wizards are identical except for the order in which you select the data source and the data destination. Figure 1.17 shows one of the screens of the Import/Export Wizard. A Quick Look at DTS C HAPTER 1 1 A Q UICK LOOK AT DTS 35 FIGURE 1.17 You can transfer multiple tables with the DTS Import/Export Wizard. To try the Import/Export Wizard, I suggest copying a couple of tables from the Pubs sample database to the Northwind sample database: 1. Open the wizard. 2. Select Pubs as the data source. 3. Select Northwind as the data destination. 4. Select the Copy tables and views from the source database Option. 5. Select a couple of tables in the list of available tables and views. 6. Uncheck Run immediately. Check Save DTS Package. Choose the SQL Server option. 7. Enter the appropriate package name, server, and security information for saving the package. 8. Select Finish to create the package. 9. Open the package in the DTS Designer to see what the wizard has created. Run the package and view the results. 03 0672320118 CH01 11/13/00 5:04 PM Page 35 Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... Features in SQL Server 2000 That Enhance Data Transformation The improvements that Microsoft has made to SQL Server 2000 have a positive impact on the use of DTS as a data transformation tool As SQL Server has become a more powerful, reliable, and scalable database, DTS is becoming a more widely used tool for data transformation There are many non-DTS changes in SQL Server 2000 that affect the DTS developer... good-quality dataData transformation software, such as Data Transformation Services in Microsoft SQL Server 2000 The purpose of this chapter is to examine the flow of data through an organization and show how DTS can be used for a significant portion of that data transformation DTS and the Flow of Data Through the Enterprise CHAPTER 3 61 Enterprise Data Structure and Data Flow It’s important to look at data. .. DTS features in SQL Server 2000 DTS Enhancements for SQL Server 2000 IN THIS CHAPTER • Top Ten New DTS Features • The New Tasks 42 43 • Transformation Task Enhancements • New Features in Other Tasks • Other New Features in DTS 47 50 52 • Other New Features in SQL Server 2000 That Enhance Data Transformation 56 CHAPTER 2 42 Getting Started with DTS PART I Microsoft first released Data Transformation. .. provided by DTS Upgrading a Database from Microsoft Access to SQL Server Microsoft has created an upsizing tool for moving a Microsoft Access database to SQL Server This tool creates the links from the Access application to the SQL database However, sometimes people will move a database from Microsoft Access (or some other database) to SQL Server, where it’s not important to maintain the user interface... sysmessages table of the master database You can move these error messages to a different instance of SQL Server 2000 by using the Transfer Error Message task This task is discussed in Chapter 15 DTS Enhancements for SQL Server 2000 CHAPTER 2 47 Transformation Task Enhancements Many of the most significant changes in SQL Server 2000 have been made in the data transformation tasks Microsoft has extended the... with SQL Server 2000 that aren’t associated with a particular task Copy Database Wizard SQL Server 7.0 has a DTS Import/Export Wizard, which captures much of the functionality of the Transform Data task and the Copy SQL Server Objects task This wizard provides a tremendous productivity boost when you’re working with many tables at the same time SQL Server 2000 adds an additional wizard for copying databases... Data Task.” The New Data Transformations SQL Server 7.0 included only two built-in choices for data transformations—Copy and ActiveX Script SQL Server 2000 now includes nine You could have created all these transformations with ActiveX Script transformation code in SQL Server 7.0, but these new choices add convenience and shorten development time The new data transformations are • DateTime String 2... more tables User-Defined Functions The Transact -SQL language in SQL Server 2000 has been extended with the ability to create user-defined functions These functions can simplify complex SQL and ActiveX script code Conclusion DTS 2000 ENHANCEMENTS FOR SQL SERVER DTS has many features in SQL Server 7.0, but there’s a lot more functionality in SQL Server 2000 Take the time to learn these new features They... object in SQL Server 7.0 and SQL Server 2000: • BulkInsertTask • ActiveScriptTask • SendMailTask Using Input Parameters in the Execute SQL Task In SQL Server 7.0, you were required to hard-code the text of a query in the Execute SQL task If you wanted to modify any part of the query dynamically, you had to use the DTS Object Model in ActiveX Scripts to change the task’s SQL property With SQL Server 2000, ... Enhancements for SQL Server 2000 CHAPTER 2 45 The Data Mining Prediction Query Task You can use some of the data mining functionality in SQL Server 2000 s Analysis Services with the Data Mining Prediction Query task, shown in Figure 2.2 To use this task, you have to create a data mining model with Analysis Services Then you can specify a prediction query and an output table for that data mining model The Data . a database between servers. • Upgrading a SQL Server database to SQL Server 2000. It’s important to be able to transfer the meta data along with the databases DTS. Upgrading a Database from Microsoft Access to SQL Server Microsoft has created an upsizing tool for moving a Microsoft Access database to SQL Server. This

Ngày đăng: 26/01/2014, 15:20

TỪ KHÓA LIÊN QUAN