我想知道是否有人可以帮我解决这个问题?我在SSIS打电话给我。我想要它做的就是创建一个文件,如果任何新记录被更新或插入表中。该表检查另一个源表以查看该表中是否有任何更改,然后将其添加到复制表中,如果对源表有任何更新或更改,我希望创建一个文件,如果不是,我们不希望它做任何事。
我测试了逻辑,一切似乎工作正常但是一旦我尝试在SSIS中运行sproc,它就会出现错误消息“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'
答案 0 :(得分:1)
添加SET NOCOUNT ON,最后根据条件选择结果集,SSIS期望结果集始终基于您配置的输出类型。您可以使用空结果集作为输出来解决问题
答案 1 :(得分:0)
注释掉所有内容,重新运行并查看是否仍然出现错误。在您收到错误之前取消注释部件。一旦收到错误,您就会知道导致问题的原因。