Você está na página 1de 9

How to execute stored procedure in ssis:

1. Create normal stored procedure in sql:


USE [practice]
GO
/****** Object: StoredProcedure [dbo].[sp_AddrssbySid]
01/11/2015 21:57:05 ******/
SET ANSI_NULLS ON
GO

Script Date:

SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_AddrssbySid]
(
@S_id int,
@C_name varchar(15)
)
as
begin
select *FROM AdventureWorks.Person.Address
where StateProvinceID=@S_id
and city=@C_name
end
GO

Normal execution:
EXEC [dbo].[sp_AddrssbySid] 14 , 'york'

Here I am passing parameters as stateprovienceid(S_id) and

city(C_name)

2.open bids create new data flow task

i)
ii)

Than click on DFT, Take OLEDB source


Select connection manager and select your connection manager

iii)

Next choose sql command in Dataaccessmode generaly we take its


table or view but our requirement is now source as procedure.

Just write this command

iv)

Create two variables for mapping parameters

Navigation ->Control flow ->right click->variables


Here we will give values for parameters
v)

Now click on parameters button in OLEDB

We can see opened new window Set

SOURCE editor

Query Parameter

There we can see two options parameters and variables


Select variables and map the variables which we created in previous screen shot
Parameters names should be start at @ symbol

Parameters

variables

@S_id

User::S_id

@C_name

User::C_name

So , now we successfully mapped our variables to parameter these parameters we put in


EXEC Statement

Come back to source editor

Change the above querylike above screen shot


EXEC [dbo].[sp_AddrssbySid]
@S_id=?,
@C_name=?

Configure the columns

Now source configured .


Take destination as OLEDB DESTINATION

CLICK ON DESTINATION

Configure oledb destination


Next click on new create table and click on ok .
Click on mapping ignore address id because we wil get datatype error thats why we
just ignore this column.

oledb destination also configured

go to control flow
Take Execute sql task and than link to data flow task

click on execute sql task

Than configure above .(this is for truncate table every time when new data appends if we
want over write data we dont consider this task .

click on ok again ok

Now run the package

Package executed success fully .


Checking data whether loaded or not

Now pass different variables

Just change the variablesand save the package dont change anything apart from that .

Checking in sql weather existing data replace with current data or not .

Thats it

Você também pode gostar