Solved

Change flow to detect file exists/not exists

Posted on 2009-05-17
4
370 Views
Last Modified: 2013-11-10
I have the following flow (see attached) which works fine, there are two import files named:

Suppliers.xml
Jobseekers.xls

The problem comes if one of these files don't exist in the directory, it fails.

I need the flow to be able to detect if only Suppliers.xml exists only run the Process Suppliers,
and if Jobseekers.xls exists only run that, but if both exist run everything.

Does anyone know how I could look at doing that?
flow.JPG
0
Comment
Question by:PeterErhard
4 Comments
 
LVL 15

Expert Comment

by:MohammedU
ID: 24409150
0
 

Author Comment

by:PeterErhard
ID: 24409643
Thanks Mohammed, but the 1st link is for the same data-type. I have two different data-types.

And the 2nd link is for a third party control, and I can't use third party controls.
0
 
LVL 22

Expert Comment

by:PedroCGD
ID: 24410879
Check the document I made inthis link and give feedback
http://biresort.net/blogs/pedrocgd/archive/2009/05/14/stepbystep-ssis-moving-huge-amount-of-files.aspx
helped?
regards,
Pedro
0
 
LVL 13

Accepted Solution

by:
TommyTupa earned 500 total points
ID: 24432852
My workaround is to simply create two configuration variables and then use the precedence contraint editor for the workflow based on the variables.

1. Setting the variables
This can be done before package execution or within a script task.  I set a configuration variable before running the package with a job step containing a script like this, then when the package executes its variables are automatically set to the configuration variable.
------------
--File Files in Directory
Declare @cmd varchar(2000),
@SourcePath varchar(200),
@Filexls int,
@Filexml int

SET QUOTED_IDENTIFIER OFF

Set @SourcePath = 'C:\Apps\Test\'
Select @Cmd ="master.dbo.XP_CMDSHELL 'dir /B " + @SourcePath + "'"

begin try drop table ##tFiles; end try begin catch end catch;

Create Table ##tFiles
(RowID int Identity,
FileName varchar(100),
FileType varchar(3)
)

INSERT ##tFiles (FileName)
EXEC(@CMD)

Update ##tFiles
set FileType = right(FileName,3)

SELECT
@FileXML =
MAX(CASE WHEN FileType = 'xml' THEN 1 ELSE 0 END),
@FileXLS =
MAX(CASE WHEN Filetype = 'xls' THEN 1 ELSE 0 END)
FROM
 ##tFiles

--Update Configuration Table
Update SSISConfig
Set ConfiguredValue =
CASE @FileXML WHEN 1 THEN 'True' ELSE 'False' END
Where ConfigurationFilter = 'Suppliers'

Update SSISConfig
Set ConfiguredValue =
CASE @FileXLS WHEN 1 THEN 'True' ELSE 'False' END
Where ConfigurationFilter = 'JobSeekers'
--------------------------------



2. Set The Precedence Constraint to the variable expression.
After your Process Temp data flow break off the rest of your steps into two branches paths; one for suppliers and one for jobseekers. So you'll end up with two arrows originating from Process Temp.


Double-click the arrow to Process Suppliers and set the constraint to evaluate to an expression such as
@[User::Suppliers]=="True".  Double-click the arrow going to ProcessJobSeekers and similarly set an expression such as @[User::JobSeekers]=="True"
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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.
Viewers will learn how the fundamental information of how to create a table.

896 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

12 Experts available now in Live!

Get 1:1 Help Now