代码之家  ›  专栏  ›  技术社区  ›  goofyui

如何将存储过程的输出映射到SQL任务中的变量?

  •  1
  • goofyui  · 技术社区  · 6 年前

    在ssis包中,我正在执行存储过程 usp_GetResult 返回2行( select PathName, FolderPath from config )

    PathName   : InboundFolderPath
    FolderPath : c:\Inbound
    
    PathName   : OutboundFolderPath
    FolderPath : c:\Outbound
    

    我要映射变量 @InboundFolderPath = c:\Inbound ,请 @OutboundFolderPath = c:\Outbound

    如何将存储过程的输出映射到SQL任务中的变量?

    2 回复  |  直到 6 年前
        1
  •  1
  •   Tab Alleman    6 年前

    我知道的唯一方法是在执行SQL任务中使用“完整结果集”,并将结果存储在对象变量中。

    然后使用脚本任务将对象变量转换为数据集,并对其进行迭代以填充标量变量。

        2
  •  1
  •   KeithL    6 年前

    我还没试过,但是怎么样:

    Declare @T Table (pathName varchar(100), folderName varchar(100))
    Insert @T Exec StoredProc params  
    
    Select max(case when PathName = 'InboundFolderPath' then folderName end ) inBound
        ,max(case when PathName = 'OutboundFolderPath' then folderName end ) outBound
    from @T
    

    然后映射