Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie to SSIS, have a basic package, how to validate if a source tabl

Status
Not open for further replies.

eo

MIS
Apr 3, 2003
809
Newbie to SSIS (2005), have a basic package, how to validate if a source table exists before I drop and recreate the table, and then load the data to it??

The first part of the Control Flow is a "Execute T-SQLstatement"

Code:
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ExchangeRate]'))
   DROP TABLE [dbo].[ExchangeRate]
GO
CREATE TABLE [ARD].[dbo].[ExchangeRate] (
[InsertedDate] datetime NOT NULL,
[RowPosition] char(1) NOT NULL,
[SourceCurrencyCode] varchar(50) NOT NULL,
[TargetCurrencyCode] varchar(50) NOT NULL,
[DateOfExchange] datetime NOT NULL,
[RatePeriod] int,
[RateType] varchar(50),
[Rate] decimal(15,8)
)
GO

It then goes to a Data Flow task, Source Query > Destination table (created in the initial control flow task)

I ideally want to validate if the source is available and that it contains data before the initial control flow task.

What is the most sound way to do this?

Thanks,

EO
Hertfordshire, England
 
A Data Flow has a pre-execute phase and validation phase. During the validation phase it will make sure that your source and destinations are available the columns are as expected.

if no records exist then the dataflow executes and shouldn't output any rows so it actually running shouldn't be an issue. If you want to do the check any how you would have to use an execute SQL task in your control flow looking for a count of records which you would assign to a variable. In the control flow from the sql task to the dataflow task you need to add an expression so that it needs a completion status of Success and Variable > 0. You will want to coalesce your results to 0 incase the count returns null.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top