Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reporting services 以动态透视表作为返回值的SSRS数据驱动订阅_Reporting Services_Dynamic Data_Reportingservices 2005 - Fatal编程技术网

Reporting services 以动态透视表作为返回值的SSRS数据驱动订阅

Reporting services 以动态透视表作为返回值的SSRS数据驱动订阅,reporting-services,dynamic-data,reportingservices-2005,Reporting Services,Dynamic Data,Reportingservices 2005,我有一个相当复杂的消息队列系统,在这个系统中,我最终执行了一个动态透视,以传递回to以及所有报告参数。我使用SSRS作为我的邮件格式提供程序和数据驱动订阅来自动传递我的电子邮件 我的问题是,当我使用UI设置我的数据驱动订阅时,SSRS阻止我继续出错 无法生成数据集。一 连接到服务器时出错 数据源,或查询无效 对于数据源。 (rscannotpreparequiry) 这是我正在做的基本情况。我为我的消息队列系统准备了这些表 CREATE TABLE MessageParameters (

我有一个相当复杂的消息队列系统,在这个系统中,我最终执行了一个动态透视,以传递回to以及所有报告参数。我使用SSRS作为我的邮件格式提供程序和数据驱动订阅来自动传递我的电子邮件

我的问题是,当我使用UI设置我的数据驱动订阅时,SSRS阻止我继续出错

无法生成数据集。一 连接到服务器时出错 数据源,或查询无效 对于数据源。 (rscannotpreparequiry)

这是我正在做的基本情况。我为我的消息队列系统准备了这些表

CREATE TABLE MessageParameters 
(
    SequenceId              int                 IDENTITY(1,1) NOT NULL,
    MessageQueueId          int                 NOT NULL,
    ParameterName           varchar(50)         NOT NULL,
    ParameterValue          varchar(300)        NOT NULL,

    CONSTRAINT PK_MessageParameters PRIMARY KEY CLUSTERED(SequenceId)
)

CREATE TABLE MessageRecipients 
(
    SequenceId              int                 IDENTITY(1,1) NOT NULL,
    MessageQueueId          int                 NOT NULL,
    ProfileId               int                 NOT NULL,

    CONSTRAINT PK_MessageRecipients PRIMARY KEY CLUSTERED(SequenceId)
)

CREATE TABLE MessageTypes 
(
    Id                      int                 NOT NULL,
    ReportName              varchar(50)         NOT NULL,

    CONSTRAINT PK_MessageTypes PRIMARY KEY CLUSTERED(Id)
)

CREATE TABLE MessageStatus 
(
    Id                      int                 NOT NULL,
    StatusName              varchar(50)         NOT NULL,

    CONSTRAINT PK_MessageStatus PRIMARY KEY CLUSTERED(Id)
)

CREATE TABLE MessageQueue
(
    SequenceId              int                 IDENTITY(1,1) NOT NULL,
    MessageType             int                 NOT NULL,
    [Status]                int                 DEFAULT(0) NOT NULL,
    Created                 datetime            DEFAULT(GETDATE()) NOT NULL,
    Modified                datetime            DEFAULT(GETDATE()) NOT NULL,

    CONSTRAINT PK_MessageQueue PRIMARY KEY CLUSTERED(SequenceId)
)
很容易理解。每封邮件可以有多个参数和多个收件人

然后,我有一个存储过程,它按消息类型获取队列中所有挂起的消息

CREATE PROCEDURE GetPendingMessageRecipients 
    @MessageType        int
AS
BEGIN


    SELECT 
        SequenceId
    INTO
        #Messages
    FROM
        MessageQueue
    WHERE
        MessageType = @MessageType
    AND
        [Status] = 0

    --###############################################################
    --###############################################################

    DECLARE @ParameterList varchar(max)
    DECLARE @To varchar(max)

    SELECT 
        r.MessageQueueId,
        ISNULL(@To, '') + p.EmailAddress + ',' AS [TO]
    INTO
        #Recipients
    FROM 
        MessageRecipients r
    JOIN
        WebProfiles p
    ON 
        r.ProfileId = p.Id
    JOIN
        #Messages m
    ON
        r.MessageQueueId = m.SequenceId

    --remove the last comma
    UPDATE 
        #Recipients
    SET
        [TO] = LEFT([TO], LEN([TO]) - 1)

    --###############################################################
    --###############################################################

    SELECT 
        p.MessageQueueId,
        p.ParameterName, 
        p.ParameterValue 
    INTO 
        #Params 
    FROM 
        MessageParameters p 
    JOIN
        #Messages m
    ON
        p.MessageQueueId = m.SequenceId

    INSERT INTO #Params
    SELECT
        MessageQueueId, 'TO', [TO]
    FROM
        #Recipients

    --###############################################################
    --###############################################################

    SELECT @ParameterList = ISNULL(@ParameterList, '') +
        '[' + ParameterName + '],'
    FROM 
        #Params
    GROUP BY
        ParameterName

    -- Remove last comma
    SET @ParameterList = LEFT(@ParameterList, LEN(@ParameterList) - 1)

    DECLARE @Query varchar(max)
    SET @Query = 'SELECT * ' +
        'FROM #Params ' +
        'PIVOT ( ' +
        '   max([ParameterValue]) ' +
        '   for [ParameterName] ' +
        '   in (' + @ParameterList + ') ' +
        ') AS pvt'

    EXEC (@Query)


END
在管理工作室里,它就像一个冠军。我获取messageid、逗号删除列表中的收件人作为TO字段,然后获取所有具有正确字段名的报表参数。但是,当我尝试输入它作为收件人数据源时,SSRS一点也不喜欢它。

如果您将

SET FMTONLY OFF
在存储过程的顶部,SSRS跳过验证,以便您可以在查询中使用临时表。

如果您将

SET FMTONLY OFF
在存储过程的顶部,SSRS跳过验证,以便在查询中使用临时表