Solved

Test to see if the source file is present.

Posted on 2014-01-07
8
280 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

744 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

16 Experts available now in Live!

Get 1:1 Help Now