J'exécute une «tâche SQL d'exécution» dans SSIS Il exécute une procédure stockée qui effectue une validation Dans la procédure stockée, j'ai une commande RAISERROR en cas de problème. Cependant, lorsque j'effectue un test, cette tâche échoue. J'ai cherché sur Google à ce sujet et trouvé beaucoup de références, mais pas de solution qui fonctionne pour moi. J'ai mis à niveau SQL Server 2005 vers Service Pack 3, mais cela ne fait aucune différence. Une référence suggère de mettre des instructions PRINT lorsqu'une exception est levée. Cela ne fonctionne pas. Alors, comment puis-je résoudre ce problème? Le code dans la procédure stockée est;SSIS (SQL Server 2005) Ne pas intercepter l'exception SQL
ALTER PROCEDURE [dbo].[usp_VAL_Journey]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @Month AS INT
, @Year AS INT
SELECT TOP 1 @Year = DATEPART(YEAR, Date), @Month = DATEPART(MONTH, Date)
FROM dbo.JourneyLandingTable
SELECT TOP 1 *
FROM dbo.JourneyMasterTable
WHERE DATEPART(YEAR, Date) = @Year
AND DATEPART(MONTH, Date) = @Month
IF @@ROWCOUNT > 0
BEGIN
RAISERROR('JourneyMasterTable already contains data for this month.', 16, 1)
RETURN
END
SELECT DATEPART(YEAR, Date) AS year1, DATEPART(MONTH, Date) AS month1
FROM dbo.JourneyLandingTable
GROUP BY DATEPART(YEAR, Date), DATEPART(MONTH, Date)
IF @@ROWCOUNT > 1
BEGIN
RAISERROR('JourneyLandingTable contains data for more than 1 month.', 16, 1)
END
END