sql:SELECT和错误结果时没有结果

时间:2014-01-02 09:28:21

标签: sql sql-server

美好的一天, 我在执行以下代码时出现问题,显示“命令已成功完成”,但我的SELECT 问题1 没有结果,并且当执行时它也会有效但结果会改变整个时间*问题2 *例如result1:10:41再次执行20:82。我只需要它是10:41(*我在计算有多少'乔布斯是开放和关闭的

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[p_GetSocre] 
            @AUD_ID BIGINT,
        @RowCounter BIGINT,
        @DistinctCounter BIGINT,
        @NACounter BIGINT,
        @Total BIGINT,
        @Status NVARCHAR(10)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    CREATE TABLE #tmp1 
    (
        AUD_ID BIGINT,
        RowCounter BIGINT,
        DistinctCounter BIGINT,
        NACounter BIGINT,
        Total BIGINT,
        [Status] VARCHAR(MAX)
    )


    INSERT INTO #tmp1
    EXEC [p_GetCompleteIncompleteNaOverviewSCORE]

END
SELECT [Status] AS [Open/Closed], COUNT(*) AS [Status] FROM #tmp1
GROUP BY [Status]
--DROP TABLE #tmp1

其他存储过程[p_GetCompleteIncompleteNaOverviewSCORE]仅计算作业的所有部分是否已完成,然后才能为其提供打开/关闭状态

感谢名单

1 个答案:

答案 0 :(得分:0)

请在下面尝试...因为Proc会自动删除临时表,所以不需要删除临时表..

SET ANSI_NULLS ON
 GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[p_GetSocre] 
        @AUD_ID BIGINT,
    @RowCounter BIGINT,
    @DistinctCounter BIGINT,
    @NACounter BIGINT,
    @Total BIGINT,
    @Status NVARCHAR(10)
   AS
    BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

CREATE TABLE #tmp1 
(
    AUD_ID BIGINT,
    RowCounter BIGINT,
    DistinctCounter BIGINT,
    NACounter BIGINT,
    Total BIGINT,
    [Status] VARCHAR(MAX)
)


INSERT INTO #tmp1
EXEC [p_GetCompleteIncompleteNaOverviewSCORE]

 SELECT [Status] AS [Open/Closed], COUNT(*) AS [Status] FROM #tmp1
GROUP BY [Status]


 END