?
Solved

Test to see if the source file is present.

Posted on 2014-01-07
8
Medium Priority
?
286 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
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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.
Suggested Courses

777 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