Here is a possible option that can give you an idea to achieve this. The example checks if today's date is a holiday by checking against a table containing list of holidays. Rest of the package tasks will execute only if today's date is not a holiday. The example uses SSIS 2008 R2
and SQL Server 2008 R2
database.
Step-by-step process:
Create a table named dbo.Holidays
and stored procedure named dbo.CheckTodayIsHoliday
using the script given under SQL Scripts section. Populate the table as shown in screenshot #1.
On the SSIS package, create two variables named RecordCount
and SQLProcedure
. Populate them with values as shown in screenshot #2. also, create an OLE DB Connection to connect to SQL Server database. I have named it as SQLServer in this example. Refer screenshot #3. The example uses Data Source instead of normal connection. That's why the icon is different in the screen shot.
On the SSIS package, place a Data Flow task
and within the data flow task place an OLE DB source
and Row count transformation
. Refer screenshot #4.
Configure the OLE DB Source
as shown in screenshots #5 and #6. This will execute the stored procedure and fetch the results.
Configure the Row count transformation
as shown in screenshot #7.
On the Control Flow
, I have placed few more dummy tasks as shown in screenshot #8.
Right-click on the connector between the Data Flow Task and the next task (Sequence Container) as shown in screenshot #9.
Configure the Precedence Constraint Editor
as shown in screenshot #10.
Screenshot #11 shows package execution with today's date (June 16, 2011
) present in the dbo.Holidays
table marked as holiday. Of course, June 16, 2011 is not a holiday where I work unless I take a vacation.
Change the table data as shown in screenshot #12.
Screenshot #13 shows package execution with today's date (June 16, 2011
) not present in the dbo.Holidays
table.
Hope that helps.
SQL Scripts:
CREATE TABLE [dbo].[Holidays](
[Id] [int] IDENTITY(1,1) NOT NULL,
[HolidayDate] [datetime] NULL,
CONSTRAINT [PK_Holidays] PRIMARY KEY CLUSTERED ([Id] ASC)
) ON [PRIMARY]
GO
CREATE PROCEDURE [dbo].[CheckTodayIsHoliday]
AS
BEGIN
SET NOCOUNT ON
SELECT HolidayDate
FROM dbo.Holidays
WHERE DATEDIFF(DAY, HolidayDate, GETDATE()) = 0
END
GO
Screenshot #1:

Screenshot #2:

Screenshot #3:

Screenshot #4:

Screenshot #5:

Screenshot #6:

Screenshot #7:

Screenshot #8:

Screenshot #9:

Screenshot #10:

Screenshot #11:

Screenshot #12:

Screenshot #13:
