MS SQL Server
  Home arrow MS SQL Server arrow Page 5 - Using Data Transformation Services, part 3...
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 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
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, part 3: Using the DTS Designer Objects (continued)
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 17
    2005-05-18

    Table of Contents:
  • Using Data Transformation Services, part 3: Using the DTS Designer Objects (continued)
  • Creating the package: opening the editor
  • Creating a Destination text file connection
  • Set up an ActiveX Script Task to access the text file
  • The FileSystemObject
  • Create a source text file
  • Create a Transform Data Task
  • Verify the results of transformation
  • Add a workflow item to rectify the package

  • 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, part 3: Using the DTS Designer Objects (continued) - The FileSystemObject


    (Page 5 of 9 )

    Since we are dealing with the text files that will be stored on the computer, a way must be provided to access the files. The FileSystemObject is a very flexible object that provides methods and properties for looking deeply into the local folders and files. The FileSystemObject can be accessed by using the CreateObject method as shown here:

    set fsys=CreateObject("Scripting.FileSystemObject")

    Once created, the methods and properties of the object provides flexible access to the files and folders.

    The HelloDTS ActiveX Script task has the following script:

    '*********************************************
    ' Visual Basic ActiveX Script
    '*********************************************

    Function Main()
    Call testfile
    Main = DTSTaskExecResult_Success
    End Function

    sub testfile()
    1 set fsys=CreateObject( "Scripting.FileSystemObject")


    2 'msgbox(fsys.FileExists("C:\Documents and Settings\computer user\My Documents\DevShed\DTS\DTSTEXT\TextDts.txt"))
     

    3 set file=fsys.GetFile("C:\Documents and Settings\computer user\My Documents\DevShed\DTS\DTSTEXT\TextDts.txt ")


    4 msgbox(file.name & vbcrlf & file.DateCreated
    & vbcrlf & file.Size)


    end sub

    The line numbers have been added for the sake of explanation, and are not created by the ActiveX Script Control. The function Main calls the procedure testfile. In line one, a FileSystemObject is created. An empty file TextDts.txt is then verified to exist in the second, commented out line, which returns true. In line three, the variable file is set pointing to the TextDts.txt file. The fourth line returns the name of the file, the date it was created and its size through a message box as shown below.

    Modify the script task to copy the above file to a text file.

    The Data Transformation task goes from source to destination. The TextFile (Destination) we created is of the destination type. Since we need to further process this text file to yield another text file, this file needs to be copied to a new file so that the copied file can become a source file. This is accomplished by adding the following lines to the testfile procedure above:

    5 fsys.CopyFile file, "C:\Documents and Settings\computer user\My Documents\DevShed\DTS\DTSTEXT\Destin.txt"
     

    6 set file2=fsys.Getfile("C:\Documents and Settings\computer user\My Documents\DevShed\DTS\DTSTEXT\Destin.txt")


    7 file2.Attributes=32

    The fifth line copies this file to another file called Destin.txt. The sixth line sets up file 2 to point to this Destin.txt file. Line seven sets up the file attribute of Destin.txt to archive (otherwise Read-Only). If the package were to be run at this stage (the SQL Server connection, the TextFile [destination] and the ActiveX Script task), the file TextDts.txt would be created, followed by the copying of the file to a newly created Destin.txt file at the desired location. Destin.txt is an exact copy of TextDts.txt, but it is not a destination type file in the context of DTS.

    More MS SQL Server Articles
    More By Jayaram Krishnaswamy


     

    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 4 hosted by Hostway