0

尝试执行我的 SQL Server 存储过程时出现此错误:当前命令发生严重错误。结果,如果有的话,应该丢弃。

这是打破的部分。任何想法为什么?谢谢!

IF  @Supervisor = 1 
AND @Calc = 1
    BEGIN
        INSERT INTO @Employees
        SELECT [Employee_No]
        FROM 
            dbo.fx_DetermineEmployeesBase
            (
                @Employee_ID
              , NULL
              , @Employee_ID
              , 2
            )

    ;WITH Applications AS
    (
         SELECT TOP 25
            ROW_NUMBER() OVER (ORDER BY vw.[Fullname] ASC, vw.[Submission_Date] DESC) AS [Row]
          , ((ROW_NUMBER() OVER (ORDER BY vw.[Fullname] ASC, vw.[Submission_Date] DESC) - 1) / @Page_Size) + 1 AS [Page_Number]
          , vw.[Employee_No]
          , CASE 
                WHEN fx.[New_Balance] > vw.[Balance] THEN vw.[Balance]
                ELSE fx.[New_Balance]
            END AS [Predicted_Balance]
        FROM vw_Employee_Leave_Application vw
            FULL OUTER JOIN @Employees e ON
                vw.[Employee_No] = e.[Employee_No]
            --This causes the error:
            --A severe error occurred on the current command.  The results, if any, should be discarded.
            CROSS APPLY dbo.fx_Employee_Leave_Type_Balance_Predict_LastRow
                (
                    NULL 
                  , COALESCE
                    (
                        CASE
                            WHEN vw.[Start_Date] <= 
                                (
                                    SELECT TOP 1 [End_Date]
                                    FROM vw_Employee_Leave_Planner
                                    WHERE
                                        [Employee_No] = vw.[Employee_No]
                                    AND [Leave_Type_No] = vw.[Leave_Type_No]
                                    AND 
                                    [Accepted] = 1
                                    AND [End_Date] > GETDATE()
                                    ORDER BY [End_Date] DESC
                                )
                            THEN
                                (
                                    SELECT TOP 1 [End_Date]
                                    FROM vw_Employee_Leave_Planner
                                    WHERE
                                        [Employee_No] = vw.[Employee_No]
                                    AND [Leave_Type_No] = vw.[Leave_Type_No]
                                    AND [Accepted] = 1
                                    AND [End_Date] > GETDATE()
                                    ORDER BY [End_Date] DESC
                                )
                            ELSE vw.[Start_Date]
                        END
                      , GETDATE()
                    )
                  , vw.[Employee_No]
                  , vw.[Leave_Type_No]
                ) fx
        WHERE
            (
                vw.[Employee_No] = e.[Employee_No]
            AND vw.Approver_No IS NULL
            )
        OR  vw.[Approver_No] =  @Approver_ID
    ),
    PageSettings AS
    (
        SELECT TOP 1
            [Row] AS [Item_Count]
          , [Page_Number] AS [Page_Count]
        FROM Applications
        ORDER BY [Row] DESC
    )

    SELECT
        [Row] AS [Row_Number]
      , [Page_Number]
      , @Page_Size AS [Page_Size]
      , [Item_Count]
      , [Page_Count]
    FROM Applications, PageSettings
    WHERE
        [Page_Number] = @Page_No
    OR  @Page_No IS NULL  
    END
4

2 回答 2

0

Restore an older backup of the database and try again, it solves mine.

于 2013-02-11T07:56:09.777 回答
0

据我在谷歌上看到的,这可能是:

链接

在 SQL Server 2005 中测试索引时,我创建了一个仅包含一个非聚集索引的表。我没有在表上创建任何聚集索引。之后我运行 SELECT 语句,它给了我以下错误。当我看到错误时,我感到非常惊讶。它说 Msg 0,这意味着这个错误对于 Microsoft 来说不是已知的错误,它可能是错误。

消息 0,级别 11,状态 0,行 0 当前命令发生严重错误。结果,如果有的话,应该丢弃。Msg 0, Level 20, State 0, Line 0 当前命令发生严重错误。结果,如果有的话,应该丢弃。

我确实搜索了错误,发现它肯定是错误,并且有 SQL Server 2005 Service Pack 2 的累积更新包 6,它修复了这个问题。您可以从此处下载 SQL Server 2005 Service Pack 2 的累积更新包 6。

若要解决此问题,请向 Microsoft 在线客户服务提交请求以获取累积更新包。要提交获取累积更新包的联机请求,请访问以下 Microsoft 网站: http: //go.microsoft.com/ ?linkid=6294451

另一个下载链接

于 2012-08-29T14:29:53.867 回答