How do I check for a flat file in an SSIS package?
I have a tab delimited file in a common path. I have set this flat file as a connection in an SSIS package. I want my package to check for the existence of a file before trying to convert it and import it into a database table. I'm new to this and I'm replacing a script that checks for the existence of a file by hard-coding the path into the script (which I would like to avoid).
Is there a way to refer to the path from the connection from within a script or some other method that I am not aware of?
source to share
Try this, I think it goes where you want.
Note the assignment of the Path to the variable in SSIS.
http://dichotic.wordpress.com/2006/11/01/ssis-test-for-data-files-existence/
Here's a different (maybe more elegant) solution.
http://blogs.pragmaticworks.com/devin_knight/2009/08/does-file-exist-check-in-ssis.html
source to share
I ended up using a combination from madcolor articles:
Public Sub Main()
Dts.TaskResult = Dts.Results.Success
Dim myFlatFileCM As ConnectionManager = Dts.Connections("MyFlatFile")
If Not File.Exists(myFlatFileCM.ConnectionString) Then
Dts.TaskResult = Dts.Results.Failure
End If
End Sub
"MyFlatFile" is the name of the connection manager. Note that this has been done since SQL Server 2005.
source to share