Solved

Test to see if the source file is present.

Posted on 2014-01-07
8
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
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 backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

695 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