遇到错误:a cursor with thename ‘ ‘ already exists,想要看是什么代码导致的。找到下面几种方法.
--测试声明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
结果: