Solved

Change flow to detect file exists/not exists

Posted on 2009-05-17
4
361 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

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.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

758 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

20 Experts available now in Live!

Get 1:1 Help Now