我一直在处理 SSRS 报告,对于我的一个存储过程,它使用动态 SQL,因此我收到此错误:
An item with the same key has already been added.
所以我用谷歌搜索了这个错误,但对我来说仍然很模糊..
我的存储过程接受了一些切换类型的参数,如下所示:
@CompleteType INT = NULL,
/*
* 0 - Routed
* 1 - Targeted
* 2 - Offerwall
*/
@SourceType BIT = NULL,
/*
* Works if @AccountID is not null
* (should only be used if @AccountID has a single value)
*
* 0 - Owned by @AccountID
* 1 - External (not owned by @AccountID)
*/
@SurveyStatus INT = NULL,
/*
* NULL - All Surveys
* 0 - Completes Approved Surveys
* 1 - Invoiced Surveys
*/
@IsSupplierUser BIT = 0
/*
* used to decide whether to display FEDSurveyName or SupplierSurveyName
问题出现在这两个代码块中(它们不连续):
-- Initial Survey Name
IF @IsSupplierUser = 0
SET @SQL += CHAR(13) + CHAR(9) + N' ,ts.FEDSurveyName as ''Initial Survey Name'''
ELSE
SET @SQL += CHAR(13) + CHAR(9) + N' ,ts.SupplierSurveyName as ''Initial Survey Name'''
然后这个:
-- Complete Survey Name
IF @IsSupplierUser = 0
SET @SQL += CHAR(13) + CHAR(9) + N' ,cs.FEDSurveyName as ''Complete Survey Name'''
ELSE
SET @SQL += CHAR(13) + CHAR(9) + N' ,cs.SupplierSurveyName as ''Complete Survey Name'''
我们有 a ts.FEDSurveyName
和 a cs.FEDSurveyName
,并且SupplierSurveyName
分别相同。我很感激任何提示!谢谢