SSIS: Passing paramters to and from stored procedure
Execute SQL task could be used for this purpose. The applications are very practical and many. If you can not get this to work and are still getting confusing error messages then I recommend installing SQL SERVER 2005 SERVICE PACK 1.
Check out Kirk's post on parameter setup based on connection type such as ado.net or oledb etc.
Here is the test proc
CREATE PROCEDURE [dbo].[testproc]
@i int ,
@j int output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
set @j = 33
END
and here is the test script to execute it.
USE ADVENTUREWORKS
GO
declare @m int
exec dbo.testproc @i = 2, @j = @m output
print @m
Inside the ssis package:
Variable settings are as follows:
Name = i
scope = execute sql task
data type = int32
value = 1
Name = i
scope = package
data type = int32
value = 1
In the Execute SQL Task Editor here are the important settings
--General Tab
Resultset = none
connection type = ole db
connection = servername.AdventureWorks
sqlsourcetype = direct input
sqlstatement = exec dbo.testproc @i = ?,@j = ? output
-- Parameter Mapping
variable name = User::i
direction = input
data type = long
parameter name = 0
variable name = User::q
direction = output
data type = long
parameter name = 1
Execute the package and if every thing goes well execute sql task will turn green. If not then please check the following
variables: check the scope, data type etc, upper case or lower case name, make sure that name is exactly the same.
Inside the execute sql task editor:
Check the following settings: Result Set, connection type, connection, specially check the sql statement and parameter mapping. Make sure that that parameter name have the correct ordinal numbers and directions are setup up correctly as input and output and double check the data type.
If it still does not work then check out the error messages in the output window and trouble shoot accordingly.
HTH..
ZULFIQAR SYED
Recent Comments