如何使用参数在SSIS中运行动态查询 [英] How to run dynamic Query in SSIS with parameters
问题描述
有人可以告诉我如何使用SSIS中的参数运行SQL的动态查询
已在SSMS中完成
can some one tell me how to run dynamic query of SQL using parameters in SSIS
Already did in SSMS
DECLARE @Table1 NVARCHAR(100) = 'ABR_temp.dbo.Clist'
DECLARE @query NVARCHAR(max)
SET @query = 'Select * from ' + @Table1
EXEC (@query)
这里是问题
----------------------
执行SQL任务框1
SQL声明:
here is the problem
----------------------
Execute SQL Task Box 1
SQL Statement:
Select 'ABR_temp.dbo.Clist' as Table1
-Result Set-
结果名称=表1
Varibale名称=用户::表1
------------ ---------
执行SQL任务框2
SQL语句:
-Result Set-
Result Name=Table1
Varibale Name=User::Table1
---------------------
Execute SQL Task Box 2
SQL Statement:
Select * from ?
-parameter mapping-
变量名称:User :: Table1
参数名称:0
错误是
--------
错误:0xC002F210执行SQL任务2,执行SQL任务:执行查询
select * from?失败,出现以下错误:语法错误,权限违规或其他非特定错误。可能的失败原因:查询问题,ResultSet属性设置不正确,参数设置不正确或连接未正确建立。
-parameter mapping-
Variable name: User::Table1
Parameter name: 0
ERROR is
--------
Error: 0xC002F210 at Execute SQL Task 2, Execute SQL Task: Executing the query "
select * from ?" failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
推荐答案
thnx我发现了很多解决方案...效果很好
SSIS:执行SQL任务,OLE DB源组件或Datareader组件内的映射参数 [ ^ ]
thnx alot i found out the solution... works great
SSIS: Mapping parameter inside of a Execute SQL Task, OLE DB Source Component or Datareader component[^]
这篇关于如何使用参数在SSIS中运行动态查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!