Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Test to see if the source file is present.

Posted on 2014-01-07
8
Medium Priority
?
287 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

A couple of weeks ago, my client requested me to implement a SSIS package that allows them to download their files from a FTP server and archives them. Microsoft SSIS is the powerful tool which allows us to proceed multiple files at same time even w…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

618 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