2016-07-12 24 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 
相关问题