SQL SERVER - 如何检测游标cursor是否打开?
IF CURSOR_STATUS('global', 'mycursor') >= 0
BEGIN
PRINT 'Cursor exists and is open';
END
ELSE
BEGIN
PRINT 'Cursor does not exist or is not open';
END;
REF:https://stacktuts.com/how-to-check-if-cursor-exists-open-status-in-sql