OLE DB提供程序未返回基于SQL命令的行集

OLE DB提供程序未返回基于SQL命令的行集,sql,ssis,Sql,Ssis,我想知道是否有人能帮我解决这个问题?我正在SSIS中调用存储过程。如果有任何新记录被更新或插入到表中,我只想让它创建一个文件。该表检查另一个源表,查看该表中是否有任何更改,然后将其添加到复制表中,如果源表有任何更新或更改,我希望创建一个文件,如果没有,我们不希望它执行任何操作 我已经测试了逻辑,似乎一切正常,但一旦我尝试在SSIS中运行存储过程,它就会给出错误消息,OLE DB提供程序不会返回基于SQL命令的行集。起初我认为这意味着它出错了,因为没有返回任何行,但即使有行返回,我仍然会收到相同的

我想知道是否有人能帮我解决这个问题?我正在SSIS中调用存储过程。如果有任何新记录被更新或插入到表中,我只想让它创建一个文件。该表检查另一个源表,查看该表中是否有任何更改,然后将其添加到复制表中,如果源表有任何更新或更改,我希望创建一个文件,如果没有,我们不希望它执行任何操作

我已经测试了逻辑,似乎一切正常,但一旦我尝试在SSIS中运行存储过程,它就会给出错误消息,OLE DB提供程序不会返回基于SQL命令的行集。起初我认为这意味着它出错了,因为没有返回任何行,但即使有行返回,我仍然会收到相同的错误消息。我可以在SSIS中解析查询并预览结果,但运行时它仍然会变为红色,并给出错误消息

下面是我的存储过程的代码。任何帮助或想法都将不胜感激

    USE [dev02]
    GO
    /****** Object:  StoredProcedure [dbo].[usp_VoidReasons]    Script Date:            8/25/2016 11:54:44 AM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    /*--------------------------------------------------------------------------   ----
    Author:         Andrej Friedman
    Create date:    07/27/2016
    Description:    This sproc assists SSIS in creating a file but only when a                    new row has been added to the VoidReasonsLookup table 
    that didnt exist there before or if the code or description has changed in    that table. The table is compared to the prod1.dbo.miscde 
table for diferences and only for the Void Reasons of that table (mcmspf = 'cv'). 
History:        
SampleCall:     EXEC [dbo].[usp_VoidReasons]
    --truncate table dev02.dbo.VoidReasonsLookup
    --select * from dbo.VoidReasonsLookup
    --update VoidReasonsLookup set Description = 'BB' where Description = 'BENEFIT CODE ADJUSTMENT'
------------------------------------------------------------------------------*/


ALTER proc [dbo].[usp_VoidReasons] 

as


declare @ImportDate as date = CONVERT (date, GETDATE()) 


insert into VoidReasonsLookup (Code, [Description])


--Change #1 -- New Code and Description

--This will insert a new row in the VoidReasons table where the Code and description doesnt exist there but exists in the source table. 

select (M.mcmscd_1 + M.mcmscd_4) as Code, mcmsds as [Description] from prod1.dbo.miscde M 

left join VoidReasonsLookup VL

on M.mcmscd_1 + M.mcmscd_4 = VL.Code

where M.mcmspf = 'cv'

and VL.Code is null



--Change #2 -- Code dropped off source table so we need it gone from the VoidReasons table

--This will delete rows where the Code doesnt exists in the source table any longer


delete from VL from VoidReasonsLookup as VL

left join prod1.dbo.miscde as M

on VL.Code = M.mcmscd_1 + M.mcmscd_4

where M.mcmscd_1 + M.mcmscd_4 is null


--Change #3 -- Description has changed for a certain code in the source table.

--This will update the Description to the source table if it is different in the VoidReasons table and update the ImportDate to today when that update took place. 


update VL

set VL.[Description] = M.mcmsds,

VL.ImportDate = @ImportDate

from dbo.VoidReasonsLookup as VL

join prod1.dbo.miscde as M 

on VL.Code = M.mcmscd_1 + M.mcmscd_4

where VL.[Description] <> M.mcmsds

and M.mcmspf = 'cv'




--This will give back everything in the VoidReasons table but only if todays date is the same as the ImportDate column of the table. 

--This will mean that today a record was inserted or updated. 


If exists(select ImportDate from VoidReasonsLookup

where ImportDate = @ImportDate)

select * from VoidReasonsLookup

else 

print 'no changes detected in VoidReasons table'

注释掉所有内容,重新运行,看看是否仍然出现错误。取消注释部分,直到出现错误。一旦出现错误,您就知道是什么导致了问题。

添加SET NOCOUNT ON并在最后选择resultset basedon condition,SSIS希望resultset始终基于您配置的输出类型。您可以使用空结果集作为输出,这将解决问题

谢谢您的回复。我不确定我是否完全理解。你是说如果我告诉SSIS去处理一个空的结果集,应该没问题吧?即使我得到一个返回SSIS的结果,仍然有错误。你是说在SSMS中?在SSMS中,存储过程运行正常,逻辑似乎良好。它只在SSIS中运行,不会出现错误。