遇到錯誤:A cursor with thename ' ' already exists,想要看是什么代碼導(dǎo)致的。找到下面幾種方法.
--測試聲明Cursor并且打開
DECLARE vend_cursor CURSOR
FOR SELECT * FROMPurchasing.Vendor
OPEN vend_cursor
FETCH NEXTFROMvend_cursor;
--使用下面的三種方法都可以
SELECT ec.session_id,ec.name,ec.properties,ec.creation_time,ec.is_open,ec.writes,ec.reads,t.text
FROM sys.dm_exec_cursors(0)ec
CROSS APPLYsys.dm_exec_sql_text(ec.sql_handle)t
dbcc activecursors(0)
SELECT *FROMMASTER..SYSCURSORS