0

在谷歌上尝试了很多之后,我运气不好,我在这里寻求你的帮助。我正在尝试使用存储过程在 SSRS 中创建数据集,但我遇到了困难。有人可以告诉我我所缺少的吗?

这是我的存储过程的样子:

    CREATE PROCEDURE [dbo].[usp_GetUserData](@ReportRunDate DATE        = NULL,
                                         @ReportName    VARCHAR(50) = NULL)
AS
     BEGIN
         WITH CTE
              AS (SELECT [USER_ID], [Name], [Address], [DOB], [Status], [UserType], [DateAdded]
                  FROM [dbo].[User_Information]
               WHERE [DateAdded] = @ReportRunDate)
              SELECT *
              INTO #UserReport
              FROM CTE;
         IF(@ReportName = 'Internal')
             BEGIN
                 SELECT [USER_ID], [Name], [Address], [DOB]
                 FROM #InternalReport
                 WHERE [UserType] = 'Internal';
                 SELECT *
                 FROM #InternalReport;
             END;
         IF(@ReportName = 'External')
             BEGIN
                 SELECT [Name],[Status]
                 FROM #ExternalReport
                 WHERE [UserType] = 'External';
                 SELECT *
                 FROM #ExternalReport;
             END;
     END;

正如许多人在 SO 中提到的那样,我已经更改了参数的顺序,但这也无济于事。

4

0 回答 0