SSIS ole db source using stored procedure cannot retrieve meta-data for columns

时间:2015-06-15 14:49:48

标签: sql stored-procedures ssis

I'm using a stored procedure for ole db source in SSIS. It always pops out error when I click on "Columns" panel. However, the same query executes successfully in SSMS and in "Build Query..." window. enter image description here

In the stored proc., no temp table but table variable is used. I did a lot research online but all similar cases seem to be caused by temp tables.

1 个答案:

答案 0 :(得分:2)

对于SSIS使用存储过程作为数据源,存储过程必须只产生一个可能的结果集结构。

您可以让SSIS通过以下内容开头查看复杂存储过程的元数据:

IF 1=2
 SELECT
   1 AS MyIntColumn
 , 1.11 AS MyMoneyColumn
 , 'test' AS MyVarcharColumn
ELSE
 BEGIN
 ... 

事情是在1 = 2块中放入一个SELECT语句,它将返回存储过程最终返回的Columns和DataTypes。这样SSIS可以查看第一个语句,并知道从存储过程中期望的列和数据类型。这就是它所需要的一切。在第一次选择中它不需要“真实”数据。它可以是所有虚拟值,甚至不是来自表格。