我在 SSRS 中遇到了一个奇怪的错误,在一个带有许多下拉参数的报告(它被放入一个存储过程中)中:
Query execution failed for dataset 'DataSet1'.
Must pass parameter number 3 and subsequent parameters as '@name = value'. After the form '@name = value' has been used, all subsequent parameters must be passed in the form '@name = value'
我对这里发生的事情一无所知 - 是什么意思@name = value
。
我在网上搜索,有人提到你应该改变存储过程?
这是我的存储过程的上半部分的外观:
USE [FederatedSample]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[prc_RPT_Select_BI_Completes_Data_View_2]
@FromDate DATETIME,
@ToDate DATETIME,
@AccountIDs VARCHAR(max) = null,
@ClientIDs VARCHAR(max) = null,
@SupplierIDs VARCHAR(max) = null,
@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
*/
AS
BEGIN
SET NOCOUNT ON
DECLARE @SQL NVARCHAR(MAX) = N'',
@Params NVARCHAR(MAX)
IF @AccountIDs is not null
BEGIN
SET @SQL += N'DECLARE @AccountIDs VARCHAR(MAX) = @pAccountIDs; '
END
IF @ClientIDs is not null
BEGIN
SET @SQL += N'DECLARE @ClientIDs VARCHAR(MAX) = @pClientIDs; '
END
IF @SupplierIDs is not null
BEGIN
SET @SQL += N'DECLARE @SupplierIDs VARCHAR(MAX) = @pSupplierIDs; '
END
SET @SQL += N'
SELECT bi.SupplierID as ''Supplier ID''
,bi.SupplierName as ''Supplier Name''
,bi.PID as ''PID''
,bi.RespondentID as ''Respondent ID''
,lk_slt.Name as ''Entry Link Type''
,ts.SurveyNumber as ''Initial Survey ID'''
稍后在存储过程中。它会做这样的事情来分割字符串:
IF @AccountIDs is not null
BEGIN
SET @SQL += CHAR(13) + CHAR(9)
SET @SQL += N' and bi.AccountID in (SELECT CAST(val as INT) FROM dbo.Split(@AccountIDs, '','