Unable to pass a variable value to a stored procedure in ssis

☆樱花仙子☆ 提交于 2019-12-10 14:50:02

问题


When executing an SSIS package, the following error appears:

[OLE DB Source [83]] Error: The SQL command requires a parameter named "@Sales_person", which is not found in the parameter mapping.

[SSIS.Pipeline] Error: OLE DB Source failed the pre-execute phase and returned error code 0xC0207014.

Below is the screenshot of my OLE DB Source editor

I do see Param direction tab in Set Query parameters, how is that used? In my case will I be using Input or Output or InputOutput


回答1:


After searching i didn't find a solution for this issue that worked for me. Ther are many suggestions like adding SET NOCOUNT ON before the execute command. Below some related links:

  • http://geekswithblogs.net/stun/archive/2009/03/05/mapping-stored-procedure-parameters-in-ssis-ole-db-source-editor.aspx
  • http://www.sqlservercentral.com/articles/Data+Flow+Task+(SSIS)/117370/
  • http://www.ssistalk.com/2007/10/10/ssis-stored-procedures-and-the-ole-db-source/

You can do a workaround

Declare a SSIS variable (assuming @[User::Query])

Set @[User::Query] property EvaluateAsExpression = True and use the following expression

"EXEC [dbo].[GetDales_Person_data] " + @[User::Sales]

if @[User::Sales] is a string use the following

"EXEC [dbo].[GetDales_Person_data] '" + @[User::Sales] + "'"

Then In OLEDB Source use SQL Command from variable and select @[User::Query]




回答2:


The problem is with the mapping. See image and source below to make corrections, you should set it to:

Exec [dbo].[GetSales_Person_Data] @Sales_person = ?

Source - geek with blogs




回答3:


There seems to be a problem with mapping parameters directly into the EXEC statement.

One way you can get around this is to use:

DECLARE @SalesPerson int = ? -- or whatever datatype

EXEC [dbo].[GetSales_Person_Data] @SalesPerson


来源:https://stackoverflow.com/questions/43619211/unable-to-pass-a-variable-value-to-a-stored-procedure-in-ssis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!