< xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
I have a SQL Task that calls a stored procedure and returns an output parameter. The task fails with error "Value does not fall within the expected range."
The Stored Procedure is defined as follows:
Create Procedure [dbo].[TestOutputParms]
@InParm INT ,
@OutParm INT OUTPUT
as
Set @OutParm = @InParm + 5
The task uses an OLEDB connection and has a source type of Direct Input. The SQL Statement is
Exec TestOutputParms 7, output
| Variable Name | Direction | Data Type | Parameter Name |
| User::OutParm | Output | LONG | @OutParm |
| Name | Scope | Data Type | Value |
| OutParm | Execute SQL Task1 | Int32 | 0 |
I traced the SQL statement in profiler and the RPC completed statement appears to set the output parameter correctly:
declare @p3 int
set @p3=12
exec sp_executesql N'Exec TestOutputParms 7, @P1 output',N'@P1 int OUTPUT',@p3 output
select @p3
From this I assume that the problem lies in the mapping of the parameter data type to the variable data type but I can’t see what is wrong. I have also tried the same thing mapping a string variable to a varchar parameter but had the same result. What am I doing wrong
I am running the latest version of SQL 2005:
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86)
Oct 14 2005 00:33:37
Copyright (c) 1988-2005 Microsoft Corporation
Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 2)

Execute SQL Task – Output Parameter on Stored Procedure causes task to fail.
Honza
For OLEDB Connection Types:
For ADO.Net Connection Types:
- You must select the ADO.Net connection type.
- You must set IsQueryStoredProcedure to True.
- Put only the stored procedure's name in SQLStatement.
- Ensure the data type for each parameter in Parameter Mappings matches the data type you declared the variable as in your SSIS package.
- Set your parameters Direction to Output.
- Set the Parameter Name to the same name as the parameter is declared in stored procedure.
I wrote about this on my blogHow to use OUTPUT parameters with SSIS Execute SQL Task
Le Van Dung
DmVa
Fakrudeen Ali Ahmed
You canot use named parameters with OLE DB connections, but you can with ADO.NET connections. Yes, you can map it to a package variable on the parameter mapping tab of the Execute SQL task. I don't know what the name would be.
Mark Berndt MCSD
Hi,
I am running into the same problem. I am using an OLEDB connection and have an input and output variable to the stored procedure. The input variable has a static value while the output variable is null.
If I do not define the variables in the SQLStatement box, I get the error 'Variable must be defined'. If I do, I get the 'Value does not fall within the expected range.' error.
I have marked my variables in the parameter mapping tab correctly as input and output and I am mapping String User variables to varchar parameters.
Any suggestions on what I am doing wrong
Thanks,
Arun