SQL Server Cursor Types - LOCAL Cursor & GLOBAL Cursor | SQL Server Tutorial / TSQL Tutorial

preview_player
Показать описание
Local Cursor:

The scope of Local Cursor is limited to the batch, stored procedure or trigger in which it is created. Once the Batch, Stored Procedure or Trigger is completed. The Local Cursor will not be available to use anymore.

GLOBAL CURSOR:

The scope of GLOBAL Cursor is limited to the connection in which it is created. You can use GLOBAL CURSOR in multiple batches, you can open in first and fetch the data in second. You can also open the GLOBAL CURSOR in one Stored Procedure and Fetch the Data in Next Stored Procedure as long as they are using the same connection.

Blog post link for the video with scripts
Рекомендации по теме
Комментарии
Автор

I followed the same thing as given in the video. (I created global cursor)

But the only difference is I executed exec Dec_Cursor_Customer in one window. It executed successfully.

I opened another window by pressing "CTRL+ N". in that I executed exec Fetch_Cursor_Customer.

It throw ed error as  A cursor with the name 'Customer_cursor' does not exist.

newname