Avatar of ktQueBIT
ktQueBIT asked on

How to setup a single DTS package to handle loading multiple files

I have created a DTS package using SQL Server 2000 that loads data into SQL server from an external set of extracted data files.  The problem is that the DTS package is currently loading the data from excel spreadsheets and using the Excel 97-2000 source object in DTS it forces you to map to a specific file name.  My problem is that the data files that the DTS package is going to be loading are coming from several different sources.  The thing is the content of the data files is exactly the same as it gets pulled from each source so the column in all the data files are identical so they can be loaded by the same DTS package.  My problem is that I do not know of a good way to have the DTS pakcage handle a set of files.  In this case the files will have the exact content structure but the acutal file names will vary based on the source.  Does anyone know of a good way to have DTS load about 20 files worth of data into SQL server using a single DTS package where the only difference will be the names of the files.  Any ideas guidance or examples would be greatly appreciated.
Microsoft SQL Server

Avatar of undefined
Last Comment
dawuf

8/22/2022 - Mon
Yveau

How about letting the DTS import a file called 'current.xls' and make a vbscript that will loop over all files and copies every single one to current.xls so the package can import it and than let the loop get the next excel file for the DTS? Can you still follow me ?

Hope this helps ...
ASKER
ktQueBIT

I do follow you, but to make sure I really do, you are saying have  directory where all the files are uplaoded to, then use a VBscript to go through and change the names of thei file to current.xls so that the DTS package can process it.  Then once the file is processed rename it to whatever and then pick up the next file to rename to current.xls for processing.  If this is accurate do you have an example of vbscript code that wouild do this.  I searched google for a sample of something like this but was never able to find anything.  Also would I setup some kind of loop in the vbscript to trigger the DTS package?  Thanks.
Yveau

Almost ... If I were you, I would copy each file to 'current.xls' (or whatever ...) and not rename the original files.
But the rest is as I had it in mind, yes.
... :-) hehe ... example code ... well ... ehm ... I'm only a simple database guy, so that wouldn't be my strong part. However I will start up my laptop and see what I can fins in my DTS packages for you ...

I'll get back to you later on this ...
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Yveau

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
dawuf

Yveau.
I am currently using this logic in DTS job I am developing.  I have sa  rights my login.  When I run the code  under my login, there is not a problem. However when running it under sa in the scheduled tasks, I get a file not found error on the fso.getfolder(<folder>) . The DBA has confirmed that the sa has rights to the directory and server has rights to the directory.  So I am a little concerned that when the author runs the through a scheduled task, he might run into the same problem. I have attached the code snippet from my code. The code snippet is doing a count of files in the folder. inputpath is stored in a Global variable fed by a .ini file via Dynamic properties task.
Option Explicit
Function Main()
dim fso, looptotal, inputpath,f,f1,fc,i, fname
'*****SetUp********
Set fso = CreateObject("Scripting.FileSystemObject")
'*****Setup Our Totals and inital filename globals******
 
inputpath = DTSGlobalVariables("inputpath").value
Set f =fso.GetFolder(inputpath)
Set fc= f.Files
i = 0
for each f1 in fc
fname = f1.name
i = i + 1
next
 
looptotal = i
 
DTSGlobalVariables("LoopCount").Value = 0
DTSGlobalVariables("LoopTotal").Value = looptotal
DTSGlobalVariables("inputfilename") = ""
DTSGlobalVariables("outfilename") = ""
 
	Main = DTSTaskExecResult_Success
End Function

Open in new window