2016-07-12 26 views

回答

0

這應該可以解決您的錯誤。

SET SHOWPLAN_XML ON; 
GO 

Select * From Sys.Objects 
GO 

SET SHOWPLAN_XML OFF; 
GO 
0

看來你有一個光標,它保持打開狀態。你需要記住DEALLOCATE遊標(其代碼不是你問題的一部分)

DEALLOCATE {{[GLOBAL] cursor_name} @cursor_variable_name}

由於未提供打開的遊標代碼,因此無法告訴您要使用的參數。

我相信這將有助於close all cursors

-- Declare a cursor variable to hold the cursor output variable 
-- from sp_cursor_list. 
DECLARE @Report CURSOR; 

-- Execute sp_cursor_list into the cursor variable. 
EXEC master.dbo.sp_cursor_list @cursor_return = @Report OUTPUT, 
     @cursor_scope = 2; 

-- Fetch all the rows from the sp_cursor_list output cursor. 
FETCH NEXT from @Report; 
WHILE (@@FETCH_STATUS <> -1) 
BEGIN 
    FETCH NEXT from @Report; 
END 

-- Close and deallocate the cursor from sp_cursor_list. 
CLOSE @Report; 
DEALLOCATE @Report; 
GO 

最重要的是你有其他錯誤。

Msg 1067,Level 15,State 1,Line 0 SET SHOWPLAN語句必須是批處理中的唯一語句 。

由於錯誤提示,您需要將其分成不同的批次。 SET SHOWPLAN必須單獨在批處理中。有需要自己的一批

幾個命令試試這個:

SET SHOWPLAN_XML ON;  
GO 

SELECT * FROM Sys.Objects;  
GO 

SET SHOWPLAN_XML OFF;  
GO 
相關問題