参数未在 SSIS 包的运行时加载
我有简单的 SSIS 包。我的来源是 sql 命令,如下:
Select * from table1 where col in (select col from table2 where col3='VAL')
For VAL I created the variable. and for subquery I created one more variable.
Variable1=VAL
variable2=select col from table2 where col3=Variable1
所以我的来源如下:
Select * from table1 where col in (variable2)
当我运行包时,这不会替换。似乎 Variable2 未正确加载。
请指教。
I have simple SSIS package. My source is sql command as follows:
Select * from table1 where col in (select col from table2 where col3='VAL')
For VAL I created the variable. and for subquery I created one more variable.
Variable1=VAL
variable2=select col from table2 where col3=Variable1
So my source is as follows:
Select * from table1 where col in (variable2)
When I run the package, this is not replacing. Seems to be the Variable2 is not loading properly.
Please advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,如果 col 是 table1 和 table2 之间的连接列,您可以重写查询,如下所示:
我假设您在 OLE DB Source 或 ADO.NET Source 中使用此查询,并使用 SQL Command 选项读取它。
因此,将查询放入存储过程中,如下所示:
创建两个 SSIS 包变量来存储存储过程执行命令以及要传递的参数值。
在变量 StoredProcedure 的属性上,设置属性 EvaluateAsExpression > 为
True
并将表达式设置为"EXEC dbo.GetData '" + @[User::Parameter] + "'"
使用如下所示的变量
StoredProcedure
将其作为变量传递给 OLE DB 源。每当变量Parameter中的值发生变化时,存储过程的执行命令也会随之变化。First of all, if col is the joining column between table1 and table2, you can rewrite the query as shown below:
I assume that you are using this query in the OLE DB Source or ADO.NET Source to read it using SQL Command option.
So, put your query in a stored procedure as shown below:
Create two SSIS package variables to store the stored procedure execution command and also the parameter value to be passed.
On the properties of the variable StoredProcedure, set the property EvaluateAsExpression to
True
and set the Expression to"EXEC dbo.GetData '" + @[User::Parameter] + "'"
Use the variable
StoredProcedure
as shown below to pass it as a variable to the OLE DB Source. Whenever the value in the variable Parameter changes, the stored procedure execution command will change accordingly.