DEALLOCATE mycursor2
declare mycursor2 cursor for select * from hrswtim
open mycursor2
select CURSOR_STATUS('global','mycursor2')
SELECT (CASE
WHEN CURSOR_STATUS('global','DD')=1 THEN '游标的结果集至少有一行'
WHEN CURSOR_STATUS('global','DD')=0 THEN '游标的结果集为空'
WHEN CURSOR_STATUS('global','DD')=-1 THEN '游标被关闭'
WHEN CURSOR_STATUS('global','DD')=-2 THEN '游标不适用'
WHEN CURSOR_STATUS('global','DD')=-3 THEN '游标不存在' END) AS RESULT
转载 https://www.cnblogs.com/snake-hand/archive/2013/06/06/3122817.html