Solved

Test to see if the source file is present.

Posted on 2014-01-07
8
281 Views
Last Modified: 2016-02-10
Hello Experts;

I am loading FlatFiles (.CVS) into SQL 2008 and that’s not the problem.  How do I determine, using SSIS, if the flat file/s is on the server?  Using the very simple attached example where would I process some sort of error/warning message, aka a record in an audit table?
TestForSourceFile.docx
The package will be processing dozens of these files so I don’t want the package to fail, just the individual Data Flow Task that is missing its file and for it to insert a record in the audit table.
Thanks in advance.
0
Comment
Question by:wdbates
  • 4
  • 3
8 Comments
 
LVL 12

Expert Comment

by:Tony303
ID: 39763365
Hi,

I have a very simple SSIS Script Task that I use to determine if a folder has a .zip file in it. Yes, Good, process.
No, Bad, stop.

You can modify this further to perhaps fit your need.
Are your filename's that you are interested in the same every time?


    Public Sub Main()

        Dim RC As DTSExecResult

        Dim D As New IO.DirectoryInfo("\\YourUNCPath")
        If (D.GetFiles("*.zip").Length = 1) Then
            RC = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
        Else
            RC = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        End If

        Dts.TaskResult = RC
    End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:sameer2010
ID: 39764834
0
 

Author Comment

by:wdbates
ID: 39765904
Sorry for the delay in responding.  Hope to check out your suggestion later this afternoon.  All the files have the same file extention (.cvs) and I need to verify that the specific file is there before running DFT.
0
 

Author Comment

by:wdbates
ID: 39766354
Where do place your code in the Script Task?  Also, can the file path be set in the dtsConfig file?
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 12

Expert Comment

by:Tony303
ID: 39766634
Hi,

Can I just ask a couple of questions firstly.
How do you know how many or what filenames are of these .csv files that makes up a valid answer to then import?

From what you've written here...
the specific file is there before running DFT.

Are we looking for a specific file out of a bunch of .csv's in a folder?


Where do place your code in the Script Task?  Also, can the file path be set in the dtsConfig file?

Sameer's example shows the "Edit Script" button in the picture from Step 2, this is where you place the code. Please note, Sameers example is using Visual C#, my code is Visual .net.

I guess the config file can use the file path, I don't use config files, sorry. Rightly or Wrongly.

T
0
 

Author Comment

by:wdbates
ID: 39768320
In the Script Task what value do you place the ScriptLanguage in the Script Task property box?

I have attached an additional screen shot showing the property box.  I have used Sameer's example and it is working, but I like to take advantage of all learning possibilities and would like to be able to use your example as well.

I will be looking for individual files in a specified folder so as for as the File Name I can preset that as a variable.  I'm doing that as well for the Folder Path, but would like to set that at run time in the dtsConfig file.  I'll do some research and pass that on to you.

Thank you again for all your help!
ScriptLanguage.docx
0
 
LVL 12

Accepted Solution

by:
Tony303 earned 500 total points
ID: 39769404
Hi,

I have a attached my Script Task setup that works for my example. (sorry, My mistake earlier, Microsoft Visual Basic 2008 is my Script Language).

I'll be interested to hear about your progress.
Generally, when I have to deal with a variable file name, I'll use a ForEachLoop Container. I do this a lot with files that are in a fixed folder and have a datetime as part of their filename.

Cheers

T
Doc3.docx
0
 

Author Closing Comment

by:wdbates
ID: 39771381
Great job!  Everything is working great and thank you very much for your assistance.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here's a requirements document template for an integration project (also known as Extract-Transform-Load or ETL) based on my development experience as an SQL Server Information Services (SSIS) developer over the years.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.
Viewers will learn how the fundamental information of how to create a table.

863 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

26 Experts available now in Live!

Get 1:1 Help Now