Solved

SSIS help: Process multiple files

Posted on 2008-10-06
2
520 Views
Last Modified: 2013-11-30
Greetings Experts,

I have posted this question before but onobody has responded in a few days and I need to resolve ASAP.  You can see the original post here...

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/Q_23787635.html

I have this SSIS package that takes an Excel file (enrollment.xls) from a server share and imports it into a SQL database, then it deletes it from the server share.  The idea is that someone will create this enrollment-STUDYNAME.xls file and place it on the server share to be processed.  However, the problem with this approach is that there can only be one file in that location at any given time.  How do I go about programming the SSIS package to look for every file in the folder and process each?  The file does not need to be called enrollment.xls.... it can enrollment1.xls, enrollmentB.xls.   This way people can pop as many files in there to be processed and I can then schedule this SSIS package to run at night.

0
Comment
Question by:Pharmica
2 Comments
 
LVL 1

Expert Comment

by:MaxLyd
ID: 22655192
Interesting question.  This isn't a perfect solution, but it's what I would do...

Have people save the files on the share drive during the day and have some sort of cut-off when people aren't supposed to save any new files (more of an operations  issue).
 
Then write a small batch file to copy all the .xls (or whatever they are) files to the same drive under a uniform name which can be overwritten each night.  (code snippet)  You can easily schedule this within windows scheduler to run at whatever time you want.  You just need to make sure you have the correct permissions.
You can then have a linked server setup using that file through SQL server management studio.  This will allow you to query that file like a table. Not sure if that is what you had set up already with the existing import...  I find it to be the most versatile way to import data because it allows for a lot of data manipulation prior to insertin the data into tables.  Kind of takes the necessity of temp tables out of the equation a lot of times.
The only thing you will have to be concious of is that the fields will have to be EXACTLY the same in the files that are to be combined.  This is because the batch file with merely mush the data together (yup that means field names and all).  So you will have to take that into account when you are setting up the SSIS package to exclude those rows of data.

COPY \\somedrivename\*.xls "\\somedrivename\Linkedspreadsheet.xls" /Y 

Open in new window

0
 

Accepted Solution

by:
Pharmica earned 0 total points
ID: 22668714
MaxLyd:  Thanks for responding, but I was looking for a way to identify each file using a variable, so I can further use that variable to perform other functions on the file (ie, copy it, delete it, move it...etc).  I managed to get this done by using a Foreach loop sequence in SQL BI studio.    Here is the post that solved the problem.

http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/Q_23787635.html

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now