use pubs
SET NOCOUNT ON
go
DECLARE authors_cursor CURSOR KEYSET FORSELECT au_lname
FROM authors
WHERE au_lname LIKE'S%'OPEN authors_cursor
-- Declare a cursor variable to hold the cursor output variable-- from sp_describe_cursorDECLARE@ReportCURSOR-- Execute sp_describe_cursor into the cursor variableEXEC master.dbo.sp_describe_cursor
@cursor_return=@Report OUTPUT,
@cursor_source='global',
@cursor_identity='authors_cursor'-- Verify that the cursor variable contains information
IF cursor_status('variable', '@Report') !=1
print 'No information available from the cursor'ELSEBEGIN-- Fetch all the rows from the sp_describe_cursor output cursor
WHILE (@@fetch_status=0)
BEGINFETCH NEXT from@ReportENDEND-- Close and deallocate the cursor from sp_describe_cursor
IF cursor_status('variable','@Report') >=-1BEGINCLOSE@ReportDEALLOCATE@ReportEND
GO
-- Close and deallocate the original cursorCLOSE authors_cursor
DEALLOCATE authors_cursor
GO