Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Getting the name of a file in a location when the file name changes using DTS Expand / Collapse
Author
Message
Posted Sunday, March 11, 2012 11:21 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 2:08 PM
Points: 442, Visits: 800
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




Post #1264969
Posted Monday, January 7, 2013 2:03 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, June 16, 2014 11:58 AM
Points: 496, Visits: 816
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.
Post #1403870
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse