MS SQL Server
  Home arrow MS SQL Server arrow Page 4 - Using Data Transformation Services: Using ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Using Data Transformation Services: Using Global Variables with the DTS Designer
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2005-09-13

    Table of Contents:
  • Using Data Transformation Services: Using Global Variables with the DTS Designer
  • First example: Deleting Records
  • Execution
  • Second Example: Update Records
  • Execution again

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using Data Transformation Services: Using Global Variables with the DTS Designer - Second Example: Update Records


    (Page 4 of 5 )

    In this example, I will be using the same table, Orders, imported into my test bed database, TestWiz. The update query will update the RequiredDate and ShipName for the customer with CustomerID HANAR. It is assumed that all the RequiredDates have been postponed to 7/10/2005, and the shipping company changed the ship's name to Hanari Banari from their existing values shown in the Orders table.

    To implement this update procedure, we create a package as shown in the next picture, GlobalUpdate.

    Since we are changing the value of three columns at the same time, we need three parameters which we specify in the Global Variables tab of the package as shown. Using the global variable sname we change the ship's name. We also use SD, which now represents the RequiredDate and CID set equal to HANAR.

    In the Logging tab we specify a error file with location, and also choose to write to the Event Log. You need only one of these, as it is essentially the same information.

     

    The Update query will be fashioned using the DTS Designer. Create an instance of the Execute SQL Task by dropping it into the design pane. This brings up the next window shown in the picture. The SQL Statement text area will be empty to start with. What you see here is the result after building the query as described.

    By clicking the Build Query, bring up the Query designer as shown in the next picture.

    Click on the orders table in the listing on the left and drop it into the query design pane. By right clicking in the empty region of the query designer, you can pop up a menu from which you can change the query type from the default Select to the type of your choice. Here an Update type is chosen.

    Then you can click the check box in the table definition in the query designer and create the query. You may have to add the ? marks shown as these are not added.

    The query can now be tested in-situ by supplying the appropriate parameters as shown in this picture.

     

    Once the query is created, click on the Parameters... button to bring up the Parameter Mapping window. Here, you make an association between preset Global variables with the parameters needed for the query as shown in the next picture. If the parameters are not set beforehand, you can create them using the Create Global Variables... button in this window. Since the Input Global variables were created in an earlier step, they should be available in the Input Global Variables tab in the Parameters Mapping window. Now the package is complete and it can be executed as before going to Package->Execute step.

    More MS SQL Server Articles
    More By Jayaram Krishnaswamy


       · Most of the DTS tutorials on ASP free that I have written are related to using the...
     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT