为什么我会收到这些错误? SQL Server Agent 作业在 SQL Server 2008R2 中有效,但在 2016 中无效
Why in the world that I am getting these errors? SQL Server Agent job works in SQL Server 2008R2 but not in 2016
我正在升级 SSIS 包和 SQL 服务器作业并将它们迁移到 SQL Server 2016。我有一个数据流任务使用以下存储过程作为源并将其直接加载到目的地 table。该软件包在 visual studio 2016 中按预期完美运行,但在 运行 作为 SQL Server 2016 中的作业时失败并出现以下错误。但是,在同一作业中,我还有其他作业步骤包含 运行 非常好的 ssis 包,但不使用动态 sql.
背景资料:
包在 visual studio 2008 中工作得很好,在 SQL Server 2008R2 中也可以作为工作。
软件包已升级到 Visual studio 2015,在 visual studio 2015 中执行时运行良好,但在 运行 作为 sql 服务器 2016 中的作业时失败。
`USE [MyDb]
GO
/****** Object: StoredProcedure [load].[pr_Transfer_vo_DrugExposure] Script Date: 6/27/2017 11:29:00 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [load].[pr_Transfer_vo_DrugExposure] @RegistryName VARCHAR(10), @ETLLogID Int,@debug BIT = 0
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
/**************************************************************************************************
Project: EDW2.0
JIRA: ?
Developer: zbachore
Date: 2016-07-14
Description: This stored procedure just selects rows from DrugExposure table with
LoadStatusID = 2. The SSIS package will use the result set. The reason we use this
here is because the result set is dynamic - by passing RegistryName as a parameter
___________________________________________________________________________________________________
Example: EXEC load.pr_Transfer_vo_DrugExposure 'ICD', 5
___________________________________________________________________________________________________
Revision History
Date Author Reason for Change
------- ------- -----------------------------------------------------------------------
***************************************************************************************************/
--Variables:
DECLARE @ErrorMessage VARCHAR(2000) = ' ',
@DrugExposure VARCHAR(100) = @RegistryName + '_vo.DrugExposure',
@SelectSQL VARCHAR(max)
BEGIN TRY
IF 1 = 0 -- this is done only to make SSIS recognize the columns
SELECT [DrugExposureKey]
,[VisitOccurrenceKey]
,[ClientPatientID]
,[ClientPatientKey]
,[SubmissionKey]
,[RegistryElementID]
,[DrugConceptID]
,[DrugAdminConceptID]
,[EffectiveDrugDoseConceptID]
,[RouteConceptID]
,[Dosage]
,[DoseUnitConceptID]
,[NullFlavorConceptId]
,[Quantity]
,[ETLLogIDInsert]
FROM [icd_vo].[DrugExposure]
ELSE
BEGIN
SELECT @SelectSQL = '
SELECT [DrugExposureKey]
,[VisitOccurrenceKey]
,[ClientPatientID]
,[ClientPatientKey]
,[SubmissionKey]
,[RegistryElementID]
,[DrugConceptID]
,[DrugAdminConceptID]
,[EffectiveDrugDoseConceptID]
,[RouteConceptID]
,[Dosage]
,[DoseUnitConceptID]
,[NullFlavorConceptId]
,[Quantity]
,ETLLogIDInsert = ' + CAST(@ETLLogID AS VARCHAR(10)) + '
FROM ' + @DrugExposure + ' de
INNER JOIN etl.ETLSubmissionQueue sq ON de.SubmissionID = sq.SubmissionID
WHERE sq.LoadStatusID = 2'
IF @debug = 1
PRINT @SelectSQL
ELSE
EXEC(@SelectSQL)
--PRINT @SelectSQL --for debugging only
END
END TRY
BEGIN CATCH
set @ErrorMessage = 'An error occurred in stored procedure load.pr_Transfer_vo_DrugExposure ' + ERROR_MESSAGE()
RAISERROR (@ErrorMessage,
16,
1
);
END CATCH
SET NOCOUNT OFF;
END
以下是我在执行作业时遇到的错误:
Executed as user: MyDomain\myUser. Microsoft (R) SQL Server Execute Package Utility Version 13.0.1601.5 for 64-bit Copyright (C) 2016 Microsoft. All rights reserved. Started: 8:34:31 AM Error: 2017-06-27 08:34:32.34 Code: 0xC0202009 Source: Transfer Drug Exposure vo_DrugExposure Source [55] Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "The metadata could not be determined because statement 'EXEC(@SelectSQL)' in procedure 'pr_Transfer_vo_DrugExposure' contains dynamic SQL. Consider using the WITH RESULT SETS clause to explicitly describe the result set.". End Error Error: 2017-06-27 08:34:32.34 Code: 0xC020204A Source: Transfer Drug Exposure vo_DrugExposure Source [55] Description: Unable to retrieve column information from the data source. Make sure your target table in the database is available. End Error Error: 2017-06-27 08:34:32.34 Code: 0xC004706B Source: Transfer Drug Exposure SSIS.Pipeline Description: "vo_DrugExposure Source" failed validation and returned validation status "VS_ISBROKEN". End Error Error: 2017-06-27 08:34:32.34 Code: 0xC004700C Source: Transfer Drug Exposure SSIS.Pipeline Description: One or more component failed validation. End Error Error: 2017-06-27 08:34:32.34 Code: 0xC0024107 Source: Transfer Drug Exposure Description: There were errors during task validation. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 8:34:31 AM Finished: 8:34:32 AM Elapsed: 0.5 seconds. The package execution failed. The step failed.
感谢您的帮助。如果您有任何问题或需要说明,请告诉我。
非常感谢!
劫
我在从 SSIS 2008 升级到 SSIS 2014 时遇到了同样的问题。在 Data Tools 中工作正常但在生产中失败。错误信息中明确说明了解决方案:)
我正在升级 SSIS 包和 SQL 服务器作业并将它们迁移到 SQL Server 2016。我有一个数据流任务使用以下存储过程作为源并将其直接加载到目的地 table。该软件包在 visual studio 2016 中按预期完美运行,但在 运行 作为 SQL Server 2016 中的作业时失败并出现以下错误。但是,在同一作业中,我还有其他作业步骤包含 运行 非常好的 ssis 包,但不使用动态 sql.
背景资料: 包在 visual studio 2008 中工作得很好,在 SQL Server 2008R2 中也可以作为工作。 软件包已升级到 Visual studio 2015,在 visual studio 2015 中执行时运行良好,但在 运行 作为 sql 服务器 2016 中的作业时失败。
`USE [MyDb]
GO
/****** Object: StoredProcedure [load].[pr_Transfer_vo_DrugExposure] Script Date: 6/27/2017 11:29:00 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [load].[pr_Transfer_vo_DrugExposure] @RegistryName VARCHAR(10), @ETLLogID Int,@debug BIT = 0
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
/**************************************************************************************************
Project: EDW2.0
JIRA: ?
Developer: zbachore
Date: 2016-07-14
Description: This stored procedure just selects rows from DrugExposure table with
LoadStatusID = 2. The SSIS package will use the result set. The reason we use this
here is because the result set is dynamic - by passing RegistryName as a parameter
___________________________________________________________________________________________________
Example: EXEC load.pr_Transfer_vo_DrugExposure 'ICD', 5
___________________________________________________________________________________________________
Revision History
Date Author Reason for Change
------- ------- -----------------------------------------------------------------------
***************************************************************************************************/
--Variables:
DECLARE @ErrorMessage VARCHAR(2000) = ' ',
@DrugExposure VARCHAR(100) = @RegistryName + '_vo.DrugExposure',
@SelectSQL VARCHAR(max)
BEGIN TRY
IF 1 = 0 -- this is done only to make SSIS recognize the columns
SELECT [DrugExposureKey]
,[VisitOccurrenceKey]
,[ClientPatientID]
,[ClientPatientKey]
,[SubmissionKey]
,[RegistryElementID]
,[DrugConceptID]
,[DrugAdminConceptID]
,[EffectiveDrugDoseConceptID]
,[RouteConceptID]
,[Dosage]
,[DoseUnitConceptID]
,[NullFlavorConceptId]
,[Quantity]
,[ETLLogIDInsert]
FROM [icd_vo].[DrugExposure]
ELSE
BEGIN
SELECT @SelectSQL = '
SELECT [DrugExposureKey]
,[VisitOccurrenceKey]
,[ClientPatientID]
,[ClientPatientKey]
,[SubmissionKey]
,[RegistryElementID]
,[DrugConceptID]
,[DrugAdminConceptID]
,[EffectiveDrugDoseConceptID]
,[RouteConceptID]
,[Dosage]
,[DoseUnitConceptID]
,[NullFlavorConceptId]
,[Quantity]
,ETLLogIDInsert = ' + CAST(@ETLLogID AS VARCHAR(10)) + '
FROM ' + @DrugExposure + ' de
INNER JOIN etl.ETLSubmissionQueue sq ON de.SubmissionID = sq.SubmissionID
WHERE sq.LoadStatusID = 2'
IF @debug = 1
PRINT @SelectSQL
ELSE
EXEC(@SelectSQL)
--PRINT @SelectSQL --for debugging only
END
END TRY
BEGIN CATCH
set @ErrorMessage = 'An error occurred in stored procedure load.pr_Transfer_vo_DrugExposure ' + ERROR_MESSAGE()
RAISERROR (@ErrorMessage,
16,
1
);
END CATCH
SET NOCOUNT OFF;
END
以下是我在执行作业时遇到的错误:
Executed as user: MyDomain\myUser. Microsoft (R) SQL Server Execute Package Utility Version 13.0.1601.5 for 64-bit Copyright (C) 2016 Microsoft. All rights reserved. Started: 8:34:31 AM Error: 2017-06-27 08:34:32.34 Code: 0xC0202009 Source: Transfer Drug Exposure vo_DrugExposure Source [55] Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "The metadata could not be determined because statement 'EXEC(@SelectSQL)' in procedure 'pr_Transfer_vo_DrugExposure' contains dynamic SQL. Consider using the WITH RESULT SETS clause to explicitly describe the result set.". End Error Error: 2017-06-27 08:34:32.34 Code: 0xC020204A Source: Transfer Drug Exposure vo_DrugExposure Source [55] Description: Unable to retrieve column information from the data source. Make sure your target table in the database is available. End Error Error: 2017-06-27 08:34:32.34 Code: 0xC004706B Source: Transfer Drug Exposure SSIS.Pipeline Description: "vo_DrugExposure Source" failed validation and returned validation status "VS_ISBROKEN". End Error Error: 2017-06-27 08:34:32.34 Code: 0xC004700C Source: Transfer Drug Exposure SSIS.Pipeline Description: One or more component failed validation. End Error Error: 2017-06-27 08:34:32.34 Code: 0xC0024107 Source: Transfer Drug Exposure Description: There were errors during task validation. End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 8:34:31 AM Finished: 8:34:32 AM Elapsed: 0.5 seconds. The package execution failed. The step failed.
感谢您的帮助。如果您有任何问题或需要说明,请告诉我。
非常感谢! 劫
我在从 SSIS 2008 升级到 SSIS 2014 时遇到了同样的问题。在 Data Tools 中工作正常但在生产中失败。错误信息中明确说明了解决方案:)