我编写了一个存储过程,执行后将返回列BEID,Date_of_txn,Txn_Amount。在SQL Server Management Studio中运行存储过程时,我正在手动获得结果。但是我想通过SSIS中的“执行SQL”任务来执行此存储过程,并将结果存储在变量中。我该怎么办?
我不知道如何将结果存储在结果集中,因为当我运行程序包时,程序包每次都会失败。
Single Row
OLE DB
LocalHost.Fino_Detail
Exec sp_HighAmount 02, 2019
存储过程:
CREATE PROCEDURE [dbo].[sp_HighAmount]
(@Month INT,
@Year INT)
AS
BEGIN
SELECT
BEID, DATE_OF_TXN, SUM(Txn_amount) AS Txn_Amount
FROM
Fino_Sales
WHERE
SUBSTRING(Date_of_txn, 6, 2) = @Month
AND SUBSTRING(Date_of_txn, 1, 4) = @Year
GROUP BY
BEID, Date_of_txn
HAVING
SUM(Txn_Amount) BETWEEN 35001 AND 50000
AND SUM(commission_paid) > 350
END
答案 0 :(得分:2)
...
group by BEID, Date_of_txn
...
此类查询很可能返回多行,因此应将结果集切换为:“ 完整结果集”,并将输出映射到类型为< strong> Object ,还有另一个foreach
任务可以遍历每一行。
一个好的分步演练可以阅读:Execute SQL Task in SSIS Full Row Set