Archives de la catégorie SSIS – Sql Server Integration Service

Run SSIS package programmatically from csharp c# code

Introduction:

We will first create a Sql Server Integration Service that will establish a sql server connection against a table and dump it in a flat file (we will not use transformation for this sample) . After we will create a console application to run this SSIS package.

Create a SSIS Package in BIDS:

Open Business Intelligence Development Studio and creat a SSIS project:

Select the Data Flow panel or double click on Data Flow Task: it is in this panel where we will define the source, the transformation of data , and the destination. Drag and drop an OLE DB Source from Data Flow Sources panel as below:

Right click and select properties to configure OLE DB Source:

select a new  connection manager on click:

and select the table you want to dump:

Click OK.

Drag and drop  in Data Flow Destination a Flat File Destination:

Bind the OLE DB Source to Flat File Destination using the green arrow:

Right click on Flat File Destination to configure the path of the file:

Finally, click on Mappings to make your mapping:

Now, your SSIS package is ready so test it in running it:

all is fine, so we will now add to our solution a console application to run programmatically our package

in Solution Explorer pane, add a new project:

and choose an application console:

Reference Microsoft.SQLServer.DTSRuntimeWrap:

this reference is contained in this assembly:

C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SQLServer.DTSRuntimeWrap.dll

Below code snippet to run your ssis package

set the application console as startup project and run it and you will see that the SSIS package runs successfully:

, , , , , ,

Poster un commentaire

Microsoft System Center 2012

All System Center 2012 products, Service Manager, App-Controller, Orchestrator, Virtual Machine Manager, Configuration Manager, Data Protection Manager, Operation Manager -Boutougha Hassan

Microsoft Windows Server 2012

IT - Windows server 2012 - Hassan Boutougha

Microsoft Hyper-V

IT - Hyper-V - Hassan Boutougha

Microsoft SQL Server 2012

IT - SQL Server 2012 - Hassan Boutougha