Getting the name of a file in a location when the file name changes using DTS

  • To all,

    Using SQL 2000 DTS.

    I have an Excel connection named "FileToProcess".

    I have a global variable named "gvSourceFilePath" and I have assigned something like this to the Global Variable,

    "Drive Letter:\FolderName\"

    Any number of files will be dropped off in the location defined by the global variable

    and they will be named in this format ?????XXXX.xls

    ????? means I have no idea what this part of the file name will be.

    XXXX is a 4 digit number that looks something like this 4700 or 2600 or 3300, there will be 33 variations of this number and the file extension is .xls

    I am trying to use Active X to accomplish this task.

    This is the rest of my process so you will have the big picture.

    Once I get the name of the file, if it is something like ???4700.xls I want to process it by extracting certain columns to text file1 and certain columns to text file2.

    I then need to move the resulting text files to a location specific to the file name such as 4700, or 2600, or 3100 files. Again, there are 33 variations for the file names so there will be 33 different destinations.

    Here is what I have as of this time.

    Function Main()

    Dim oConn, sFilename

    ' Filename format - eXXXX.xls

    sFilename = DTSGlobalVariables("gvSourceFilePath").Value & _

    sFilename & ".xls"

    msgbox sFilename

    Set oConn = DTSGlobalVariables.Parent.Connections("FileToProcess")

    oConn.DataSource = sFilename

    Set oConn = Nothing

    Main = DTSTaskExecResult_Success

    End Function

    I would really appreciate it if someone could help me finish this off.

    I have beating my head against a wall and I am running out of time.

    Thanks to all

    Gary

  • Gary,

    Do you have to use Active X?

    I've written packages where I'll list all the files in a particular directory and then process them one at a time. I do this all from an SP that runs the import package. I manually run the SP so I haven't needed to put it in a DTS package/Job yet.

    Step 1 - List all files in directory and insert them into a log table.

    Step 2 - Then I read each file path name and process each file by executing the dtsrun command.

    Step 3- Move files to appropriate archive directory

    Okay just realized your post was almost a year old... Nvm.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply