2016-08-26 2 views
1

Ich fragte mich, ob mir jemand mit diesem Problem helfen kann? Ich rufe einen Sproc in SSIS an. Ich möchte nur, dass eine Datei erstellt wird, wenn neue Datensätze aktualisiert oder in eine Tabelle eingefügt werden. Diese Tabelle überprüft eine andere Quellentabelle, um zu sehen, ob sich etwas in dieser Tabelle geändert hat, und fügt sie dann zur Kopiertabelle hinzu, wenn Aktualisierungen oder Änderungen an der Quellentabelle vorgenommen werden sollen und wenn nicht, wollen wir sie nicht etwas tun.Ein Rowset basierend auf dem SQL-Befehl wurde vom OLE DB-Provider nicht zurückgegeben

Ich habe die Logik getestet und alles scheint gut zu funktionieren, aber sobald ich versuche, den Sproc in SSIS auszuführen, gibt es die Fehlermeldung, "Ein Rowset basierend auf dem SQL-Befehl wurde vom OLE DB-Provider nicht zurückgegeben." Anfangs dachte ich, dass dies ein Fehler ist, weil keine Zeilen zurückgegeben werden, aber selbst wenn Zeilen zurückgegeben werden, bekomme ich immer noch dieselbe Fehlermeldung. Ich kann die Abfrage analysieren und die Ergebnisse in SSIS anzeigen, aber es wird immer noch rot beim Ausführen und gibt diese Fehlermeldung.

Unten ist der Code zu meinem Sproc. Jede Hilfe oder Ideen würde so geschätzt werden!

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' 

Antwort

0

Kommentieren Sie alles aus, wiederholen Sie und sehen Sie, ob Sie immer noch den Fehler erhalten. Kommentieren Sie Teile, bis Sie den Fehler erhalten. Sobald Sie den Fehler erhalten, wissen Sie, was das Problem verursacht.

+0

Sie meinen in SSMS? In SSMS läuft die gespeicherte Prozedur einwandfrei, die Logik scheint gut zu sein. Es ist nur in SSIS, wo es nicht ohne Fehler ausgeführt wird. – LightChild77

1

Fügen Sie SET NOCOUNT ON hinzu und am Ende wählen Sie resultset basedon condition, SSIS erwartet resultset immer basierend auf dem von Ihnen konfigurierten Ausgabetyp. Sie können leere resultset verwenden, da eine Ausgabe das Problem lösen wird

+0

Vielen Dank für Ihre Antwort. Ich bin mir nicht sicher, ob ich es vollständig verstehe. Du sagst, wenn ich sage, dass SSIS mit einem leeren Resultset umgehen soll, sollte es in Ordnung sein? Selbst wenn ich ein Ergebnis bekomme, setze SSIS immer noch Fehler. – LightChild77

Verwandte Themen