MS SQL Server
  Home arrow MS SQL Server arrow Page 2 - 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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 14
    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 - First example: Deleting Records


    (Page 2 of 5 )

    In this first example, I have imported an Orders table from the Northwind database in SQL 2000 Server into my test bed database, TestWiz. The next picture shows the table from which two of the records for OrderDate 07/08/1996 will be deleted by defining the order date as a global variable.

    In order to implement this deletion, I create a new package, GlobalVal as shown. By bringing up the property window of the package (menu item Package -> Properties), the properties for the package can be set, including the global variables. In the first tab General, you may give a description, and should you require, you may choose priority, and so on. Here, only a description has been added.

    The next tab, Global Variables, is used to declare and assign value to a global variable. In the example, a global variable SD of date type has been declared with a value of 07/08/1996. The orders for this OrderDate need to be deleted. As you finish the first row, the second row drops down with default type of the next entry. If you want you may delete this row. The checkbox Explicit Global Variables is used, while global variables are going to be used in an ActiveX script. It's similar to the Option Explicit in Visual Basic. Once you check this, all global variables have to be explicitly defined for the script not to throw an exception.

    In the next tab, Logging, you can make choices to log the status of completion to the Event Log, and also any errors to an error file -- a text file at a predetermined location as shown. The next tab, Advanced, has not been used in this tutorial.

    We will be using the Execute SQL Task for the delete operation. This requires at least one connection to be specified. The next picture shows a connection to the SQL Server that will be used by the task.

    Click on the Execute SQL Task in the collections pane and draw it out on the design pane. This creates the Execute SQL Task. By clicking on the Build Query..., the query can be built up by dragging the table to the query designer pane. By default this action would create a minimalist Select query which can be changed to a Delete query. In the next example a full discussion of constructing the query and testing it in-situ is provided. For now, the SQL Statement that will be executed is as shown in the next picture. This query, when given an order date, will delete rows corresponding to that date. The parametric query is expecting a parameter, the OrderDate.

    The parameter specification is made by clicking the Parameters... button, which brings up the next window with two tabs, Input Parameters and Output Parameters. The present query requires only one parameter, the input parameter, which has already been set in the package's Global Variable settings as shown earlier. This parameter would show up in the screen as shown here.

    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

    - Windows Server 2008 as a Workstation OS
    - An Overview of Windows Server 2008 R2
    - LINQ to MySQL, Oracle and PostgreSQL Provide...
    - 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





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